cgroup_kn_lock_live(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… cgroup_kn_lock_live(9) πŸŽ€

okay so this is a page from the Kernel API Manual, and honestly bestie, it's a little locking helper that carries the whole cgroup kernfs situation on its back. no cap. let's get into it ✨


🌸 NAME 🌸

cgroup_kn_lock_live β€” the locking helper for cgroup kernfs methods 🫢


⭐ SYNOPSIS ⭐

struct cgroup * cgroup_kn_lock_live (struct kernfs_node *kn , bool
drain_offline );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • kn β€” the kernfs_node being serviced, aka the thing we're currently doing the absolute most for πŸ‘‘
  • drain_offline β€” literally "perform offline draining on the cgroup" β€” say yes and it drains, iykyk πŸ’…

πŸ’– DESCRIPTION πŸ’–

okay so picture this: this helper is to be used by a cgroup kernfs method currently servicing kn. that's the whole vibe. it's giving backstage pass energy 🎟️

here's the sequence, and it ate:

  • it breaks the active protection (yes, breaking things is on purpose here, don't panic)
  • it performs cgroup locking
  • it verifies that the associated cgroup is alive β€” vibe check, basically 🌈

returns the cgroup if alive; otherwise, NULL. so if you get a NULL back, the cgroup was not, in fact, slaying 😭

a successful return should be undone by a matching cgroup_kn_unlock invocation. matching!! don't leave your lock out here looking a mess, that's so not main character energy πŸ™ˆ

and if drain_offline is true, the cgroup is drained of offlining csses before return. yes, before. it's efficient like that πŸ’…

any cgroup kernfs method implementation which requires locking the associated cgroup should use this helper. like, not "could", should. it avoids nesting cgroup locking under kernfs active protection and allows all kernfs operations including self-removal. self-removal!! iconic behavior honestly πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯

kernel file ./kernel/cgroup/cgroup.c β€” and bestie, the friendship bracelet of cross-references is LONG, but every single one made the cut 🫢


and that's the whole page, bestie, no skips no cuts πŸ’œ this one lives under ./kernel/cgroup and the version stamp on it is October 2026 β€” so yeah, it's from the future, it's giving time traveler, and honestly? obsessed πŸŒΈβœ¨πŸ’…

πŸ“¦ where this page comes from