css_tryget(9)
β¨ 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
- 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