css_tryget(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ css_tryget ✨

okay so this is css_tryget from the Kernel API Manual, and honestly? she's a little refcount gremlin and we're obsessed πŸ’…


πŸ’– NAME πŸ’–

css_tryget β€” try to obtain a reference on the specified css 🫢


🌸 SYNOPSIS 🌸

CGROUP_REF_FN_ATTRS bool css_tryget (struct cgroup_subsys_state *css );

like, that's the whole signature, copy it exactly bestie, no cap πŸ”₯


πŸŽ€ ARGUMENTS πŸŽ€

  • css β€” the target css πŸ’« (that's the one you're trying to grab a ref on, iykyk)

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: you call this and it obtains a reference on css β€” unless it's already hit zero and is actively being released 😭 in which case, nope, no ref for you, the party's over.

The way that this function simply does not care whether css is on or offline? iconic. genuinely doesn't gaf 🌈

Now, the caller naturally needs to make sure that css is accessible β€” but here's the slay part: you don't have to be holding a reference on it. IOW, RCU protected access is good enough for this function ✨ literally that's all you need.

Returns true if a reference count was successfully obtained; false otherwise πŸ‘‘


🧚 SEE ALSO 🧚

Kernel file ./include/linux/cgroup_refcnt.h plus the whole friend group:

go read those too, fr fr πŸ’œ


heads up bestie: this is *try*get, so a false is a totally normal outcome, not a you-problem πŸ’€ always check the return value, ok? πŸ™ˆ

and that's the page!! πŸ“ brought to you from ./include/linux, dated October 2026, Kernel API Manual edition β€” mwah, love u, go get those references πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from