cgroup_ancestor(9)
π cgroup_ancestor β find ancestor of cgroup
okay so bestie, welcome to the cgroup_ancestor(9) page from the Kernel API Manual (9 = kernel API section, iykyk). this one's short and sweet and honestly kind of iconic for it. let's go π
β¨ SYNOPSIS β¨
struct cgroup * cgroup_ancestor (struct cgroup *cgrp , int
ancestor_level );
that's it. two args, one pointer out. we love a low-effort king π
π«Ά ARGUMENTS π«Ά
cgrpβ the cgroup you're tryna find the ancestor of. your starting point, your main character πΈancestor_levelβ the level of the ancestor you want, and bestie listen: it's counted starting from root. so you're measuring from the top down, not climbing up from wherever you're standing. important distinction, don't @ me π
π¦ DESCRIPTION π¦
so what does it do. it finds the ancestor of your cgroup at the specified level β starting from root β if it exists, and returns a pointer to it. simple as that π
and if cgrp doesn't have an ancestor at ancestor_level? it returns NULL. no ancestor, no pointer, no vibe. that's the whole contract π€·ββοΈ
ngl this is the chill part: it's safe to call as long ascgrpis accessible. that's the only condition, fr fr. keepcgrpalive and reachable and you're slaying β¨
π SEE ALSO π
the kernel file itself lives at ./include/linux/cgroup.h, and it's surrounded by absolute legends β go read these too, they're all part of the same cgroup friend group π
cgroup_subsys_enabled(9)cgroup_subsys_on_dfl(9)css_for_each_child(9)css_for_each_descendant_pre(9)css_for_each_descendant_post(9)cgroup_taskset_for_each(9)cgroup_taskset_for_each_leader(9)cgroup_css(9)css_is_dying(9)task_css_set_check(9)task_css_check(9)task_css_set(9)task_css(9)task_get_css(9)task_css_is_root(9)cgroup_is_descendant(9)cgroup_common_ancestor(9)task_under_cgroup_hierarchy(9)
aaaand that's the whole page, bestie. this one ships out of ./include/linux and is dated October 2026 β so mark your calendar, screenshot it, frame it, whatever π
mwah, go find some ancestors, ily π§π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms