css_for_each_child(9)
π« css_for_each_child(9) π«
okay so this is a page from the Kernel API Manual β section 9, kernel API, bestie. it's called css_for_each_child and it's about looping through a css's children. yes, that kind of css. no, not the styling one π this is cgroups-land.
π NAME π
css_for_each_child β iterate through children of a css
β¨ SYNOPSIS β¨
css_for_each_child (pos , parent );
πΈ ARGUMENTS πΈ
posβ thecss *you're using as the loop cursor. this is your little "where am i rn" pointer, she's the main character of the loop πparentβ the css whose children you're walking through. the mom, basically π
π DESCRIPTION π
so you walk parent's children. that's the whole vibe. but β and this is the important part β it must be called under rcu_read_lock. not optional, no cap. π
here's the situation with visibility, and honestly it's giving "read the fine print":
- if a subsystem synchronizes
->css_onlinewith the start of the iteration, then a css that's finished->css_onlineis guaranteed to show up in future iterations, and it will stay visible until the last reference is put. slay, stability. π¦ - a css that hasn't finished
->css_online, or that already finished->css_offline, may pop up during traversal. like, surprise guest energy. π - so it's each subsystem's own responsibility to synchronize against things going on/offline. nobody's gonna do it for you, bestie.
also! you're allowed to temporarily drop the RCU read lock during iteration. freedom ποΈ but β the caller is responsible for making sure pos stays accessible until the start of the next iteration. how? for example, by bumping the css refcnt. keep your cursor alive, basically. π«Ά
β οΈ quick recap of the two hard rules: call it underrcu_read_lock, and if you drop the lock mid-loop, you keepposreachable (bump that refcnt). otherwise it's on you, fr fr.
π SEE ALSO π
kernel file ./include/linux/cgroup.h, plus the whole friend group:
cgroup_subsys_enabled(9)cgroup_subsys_on_dfl(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_ancestor(9)cgroup_common_ancestor(9)task_under_cgroup_hierarchy(9)
and that's the whole page, periodt. π sign-off time: this one lives under ./include/linux in the kernel tree, dated October 2026, and it's css_for_each_child(9) β see you at the next iteration π§ββοΈβ¨
π¦ 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