Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drgn.helpers.linux.slab: add support for retrieving objects exclusive… #306

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wenjianhn
Copy link

…ly from per-node lists

The current implementation of for_each_allocated_object() is slow as it iterates through every physical page.

This commit adds the ability to retrieve objects exclusively from the per-node partial lists, greatly improving efficiency when searching for the source of vfs caches of dying cgroups or millions of negative dentries.

@osandov
Copy link
Owner

osandov commented Jun 20, 2023

Thanks for the PR! This returns a subset of allocated objects, correct? I.e., it will omit those which come from a full slab? My gut feeling is that this should be a separate helper with an explanation of this subtlety. My naming suggestion is slab_cache_for_each_partial_slab_object(), which is really long, so let me know if you have a better idea.

Also, how about the per-CPU partial lists? Those should be fairly quick to access, too, right?

…rtial slabs

The current implementation of for_each_allocated_object() is slow as
it iterates through every physical page.

This commit adds the ability to retrieve objects from the per-node
partial lists and the per-cpu partial slab lists, greatly improving
efficiency when searching for the source of vfs caches of dying
cgroups or millions of negative dentries.

Signed-off-by: Jian Wen <wenjianhn@gmail.com>
@wenjianhn
Copy link
Author

wenjianhn commented Jul 3, 2023 via email

@wenjianhn
Copy link
Author

wenjianhn commented Jul 4, 2023

FYI, the V2 patch helped us find out that spring-projects/spring-framework#27092 was the root cause of 3 million dentries.

Here is the script that I cooked a few minutes ago:

#!/usr/bin/env drgn

from drgn.helpers.common.format import escape_ascii_string

from drgn.helpers.linux.slab import (
    for_each_slab_cache,
    slab_cache_for_each_partial_slab_object,
)

from drgn.helpers.linux.fs import dentry_path

# docker ps  |grep container_name
# 7693d3f4bcf0        ...       6 hours ago         Up 6 hours  ...

container_id = "7693d3f4bcf0"

for slab in for_each_slab_cache(prog):
    name = escape_ascii_string(slab.name.string_(), escape_backslash=True)
    if name.startswith("dentry") and container_id in name:
        for (i, d) in enumerate(
                slab_cache_for_each_partial_slab_object(slab,
                                                        "struct dentry")):
            if (i == 10000):
                break
            print(dentry_path(d))
        break

@wenjianhn
Copy link
Author

@osandov gentle ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants