refcount_in...zero_acquire(9)
π refcount_in...zero_acquire(9) β like, the whole page, bestie
okay so first things first: this is a page from the Kernel API Manual, and the star of the show is refcount_inc_not_zero_acquire. Yes the title got squished into refcount_in...zero_acquire(9) for the header because man pages are dramatic like that. Anyway. Sit down, hydrate, let's go. π«Ά
β¨ NAME β¨
Not one but two little lines of truth, because that's just how she is:
refcount_inc_not_zero_acquireβ increment a refcount with acquire ordering unless it is0
Periodt. That's the whole vibe.
πΈ SYNOPSIS πΈ
bool refcount_inc_not_zero_acquire (refcount_t *r );
literally the whole signature. yes the space before the ) is canon, don't @ me. π
π ARGUMENTS π
rβ the refcount to increment. that's it. that's the argument. she's the main character. π
π¦ DESCRIPTION π¦
Okay so, lowkey, refcount_inc_not_zero_acquire is similar to refcount_inc_not_zero, but it provides acquire memory ordering on success. that's the entire glow-up. ngl it ate. π₯
Use this one when the memory occupied by the object might be reused to store another object β and like, think about SLAB_TYPESAFE_BY_RCU here, fr fr, that's the exact case they're pointing at. π
It provides acquire memory ordering on success, and it's assumed the caller has guaranteed the object memory to be stable (RCU, etc.). Not a "we hope," an assumption β so do your part, bestie. π
It does provide a control dependency and thereby orders future stores. Also: see the comment on top. yes, that comment. the one at the top. go read it. π
like, i cannot stress enough that the "caller has guaranteed the object memory to be stable" bit is on you. this function is not gonna do it for you. β
π RETURN π
trueβ the increment was successful, slay βfalseβ otherwise, and that's on the refcount being0π
π SEE ALSO π
the whole friend group, living in the kernel file ./include/linux/refcount.h:
refcount_set(9)refcount_set_release(9)refcount_read(9)refcount_add_not_zero(9)refcount_add_not_zero_acquire(9)refcount_add(9)refcount_inc_not_zero(9)refcount_inc(9)refcount_sub_and_test(9)refcount_dec_and_test(9)refcount_dec(9)
π§ sign-off π§
sourced straight from ./include/linux, dated October 2026, and yeah the footer still calls her refcount_in...zero_acquire(9) β iconic, truncated, no notes. bye bestie, go increment responsibly πβ¨
π¦ 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