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

Cgroup scripts #423

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Cgroup scripts #423

wants to merge 3 commits into from

Conversation

Werkov
Copy link

@Werkov Werkov commented Aug 7, 2024

This is based on discussion around cgroup.stat and as an exercise with drgn, I'm sharing it in the case anyone found that useful.
There is also a little change outside of contrib/.

BTW How is that with drgn and RCU protected data? Is it simply neglected and one should be ready for transient issues when dereferencing gone data (that's actually not specific to RCU) when debugging a running system?

Current implementation allows iterating only online csses.
Add optional argument (not to break existing) callers to iterate
also offlined nodes.
This is as racy wrt cgroup removal/subsys disabling as the original
code.

Signed-off-by: Michal Koutný <[email protected]>
Prepare for additional operations on cgroups. This rework breaks
previously accepted order of arguments '<cgroup> bpf' and requires
specifying the intended command. (No cgroups fall back to root cgrp.)

Signed-off-by: Michal Koutný <[email protected]>
Print information about cgroup_subsys_state counts associated with given
cgroup. The main purpose is to show subsys structs in offline state on
cgroup v2.

Signed-off-by: Michal Koutný <[email protected]>
Copy link
Owner

@osandov osandov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you. I have one question about the helper change.

) -> Iterator[Object]:
pos = NULL(css.prog_, "struct cgroup_subsys_state *")
while True:
pos = next_fn(pos, css)
if not pos:
break
if pos.flags & pos.prog_["CSS_ONLINE"]:
if not only_online or pos.flags & pos.prog_["CSS_ONLINE"]:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading it correctly, the kernel code doesn't limit css_for_each_child() or css_for_each_descendant_pre() to only online css, is that right? If so, then I'd prefer to just remove the CSS_ONLINE check entirely, since it's better for helpers to be as similar as possible to the kernel functions they are based on.

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