cgroup_css(9)
π cgroup_css(9) β the kernel API manual, but make it make sense
okay so bestie, welcome to cgroup_css(9), a page from the Kernel API Manual (yes, that manual, the one with the man page name cgroup_css). it's short, it's sweet, and it's lowkey holding up a whole chunk of the cgroup subsystem. let's get into it β¨
π NAME π
cgroup_css β grab a cgroup's css for whichever subsystem you're obsessed with π
πΈ SYNOPSIS πΈ
struct cgroup_subsys_state * cgroup_css (struct cgroup *cgrp , struct cgroup_subsys *ss );
like, that's the whole signature. struct pointer in, struct pointer out, main character energy π«Ά
π¦ ARGUMENTS π¦
cgrpβ the cgroup you're curious about, aka the one of interest πssβ the subsystem you're curious about. and listen, if you passNULLhere? it just returnscgrp->self. no cap, that's literally what it does π
β¨ DESCRIPTION β¨
so the vibe is: return cgrp's css (that's the cgroup_subsys_state, keep up bestie) that's associated with ss. simple. iconic. slay.
but here's the part where you gotta pay attention, because this is the "read the instructions before you fry your kernel" moment π:
- this function must be called either under
cgroup_mutexorrcu_read_lockβ pick one, don't just rawdog it - and the caller is responsible for pinning the returned css if it wants to keep accessing it outside those said locks. so if you're gonna be nosy after you let go of the lock, that's on you, you gotta pin it π₯
- also, this function may return
NULLifcgrpdoesn't havesubsys_idenabled. so please, please check it. fr fr. don't be the person who dereferences the NULL ππ
π SEE ALSO π
all the related lore, in its full glory, exactly as the kernel files intended:
Kernel file ./include/linux/cgroup.h
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)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)
that's the whole friend group, go say hi π«Άπ
π a lil reminder before you go:cgroup_mutexorrcu_read_lock, and pin that css if you're staying past the lock. the kernel does not accept excuses, bestie.
and that's the page!! tysm for reading, mwah π made with love from ./include/linux, version dated October 2026, and the page itself is cgroup_css(9). see you in the next manpage, bestie πβ¨π¦
π¦ 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