From 372820f159b673c3ed7228b8a94d499f7b43137c Mon Sep 17 00:00:00 2001 From: Stephen Brennan Date: Fri, 3 Jan 2025 11:38:36 -0800 Subject: [PATCH] kernfs,memcg: access state flags via CSS_ONLINE 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 --- drgn_tools/kernfs_memcg.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drgn_tools/kernfs_memcg.py b/drgn_tools/kernfs_memcg.py index 56eb356..bbaf6ae 100644 --- a/drgn_tools/kernfs_memcg.py +++ b/drgn_tools/kernfs_memcg.py @@ -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. @@ -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]: