cgroup_css(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 pass NULL here? it just returns cgrp->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_mutex or rcu_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 NULL if cgrp doesn't have subsys_id enabled. 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

that's the whole friend group, go say hi 🫢🌈


πŸ’œ a lil reminder before you go: cgroup_mutex or rcu_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