Skip to content

Commit

Permalink
kernfs,memcg: access state flags via CSS_ONLINE
Browse files Browse the repository at this point in the history
The CSS_DYING flag was only introduced in 33c35aa481786 ("cgroup:
Prevent kill_css() from being called more than once"), which was
introduced in v4.12, but present in some backports. Since we only need
to refer to this constant in order to get the enum type, use CSS_ONLINE,
which has been present since v3.8.

Fixes: 30e57f6 ("kernfs,memcg: Add helpers to get memcg info")

Signed-off-by: Stephen Brennan <[email protected]>
  • Loading branch information
brenns10 committed Jan 3, 2025
1 parent 0212c84 commit 372820f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drgn_tools/kernfs_memcg.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ def decode_css_flags(css: Object) -> str:
:param css: ``struct cgroup_subsys_state *``
"""
CSS_DYING = css.prog_["CSS_DYING"]
# We only need the type of the enum containing the cgroup subsystem state
# constants. Unfortunately the enum is anonymous so we need to access the
# type via one of the enum members. CSS_ONLINE is present since
# a31f2d3ff7fe2 ("cgroup: introduce CSS_ONLINE flag and on/offline_css()
# helpers") in Linux 3.8, which is sufficient for our needs.
CSS_ONLINE = css.prog_.constant("CSS_ONLINE")
flags = css.flags.value_()
if not flags:
# There is no dedicated flag value to indicate a zombie cgroup.
Expand All @@ -50,7 +55,7 @@ def decode_css_flags(css: Object) -> str:
# of being pinned by some other object
return "ZOMBIE"

return decode_enum_type_flags(flags, CSS_DYING.type_, False)
return decode_enum_type_flags(flags, CSS_ONLINE.type_, False)


def for_each_kernfs_node(prog: Program) -> Iterator[Object]:
Expand Down

0 comments on commit 372820f

Please sign in to comment.