get_root_cgroup(9)
π get_root_cgroup(9) β like, the kernel API manual bestie β¨
okay so real talk, this one lives in section 9 of the Kernel API Manual and it's genuinely one of the friendliest little functions you'll ever meet π«Ά it's giving "small but mighty" and honestly? we stan.
πΈ NAME πΈ
get_root_cgroup β literally just grab the FD of the root cgroup, no biggie π
β¨ SYNOPSIS β¨
int get_root_cgroup (void );
like that's it. that's the whole vibe. π
π¦ ARGUMENTS π¦
voidβ no arguments bestie!! nothing to pass in, nothing to worry about, she takes zero input and still serves π zero. nada. zip.
π DESCRIPTION π
okay so here's the tea π β when it works, get_root_cgroup returns the file descriptor. slay. iconic. exactly what it says on the tin.
but when it fails?? it returns -1 π and β important β it prints the error to stderr, so don't go looking for the message in your stdout, she's not there, she's over in stderr land living her truth. lowkey very considerate of her tbh.
ngl, if you see that -1 come back, check your stderr before you spiral β the answer is literally right there π
π₯ SEE ALSO π₯
the whole friend group, fr fr β plus one very specific file you should absolutely go read:
Kernel file ./tools/testing/selftests/bpf/cgroup_helpers.c
enable_controllers(9)write_cgroup_file(9)write_cgroup_file_parent(9)setup_cgroup_environment(9)join_cgroup(9)join_root_cgroup(9)join_parent_cgroup(9)set_cgroup_xattr(9)__cleanup_cgroup_environment(9)cleanup_cgroup_environment(9)create_and_get_cgroup(9)get_cgroup_id_from_path(9)setup_classid_environment(9)set_classid(9)join_classid(9)cleanup_classid_environment(9)get_classid_cgroup_id(9)get_cgroup1_hierarchy_id(9)open_classid(9)
like look at that roster π the cgroup helpers really said "we're a whole squad" and honestly? periodt. go read them all, iykyk π§
π ok bye bestie, go get that root cgroup FD π
this masterpiece of a page came from ./tools/testing/selftests/bpf, dated October 2026 β and yes she's still get_root_cgroup(9) and she's still that girl πβ¨
π¦ 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