refcount_ad...zero_acquire(9)
π refcount_add_not_zero_acquire β the Kernel API Manual page, but make it make sense
okay so bestie, you're looking at refcount_add_not_zero_acquire(9) from the Kernel API Manual, and honestly? It's giving "niche but iconic." Let's get into it π
β¨ NAME β¨
refcount_add_not_zero_acquire β adds a value to a refcount with acquire ordering, unless it's 0, in which case it does absolutely nothing. queen behavior, honestly.
π¦ SYNOPSIS π¦
bool refcount_add_not_zero_acquire (int i , refcount_t *r );
πΈ ARGUMENTS πΈ
iβ the value you're adding to the refcount. the little number doing the work πrβ the refcount itself. the main character.refcount_t *and all.
π₯ DESCRIPTION π₯
okay so here's the tea: this thing saturates at REFCOUNT_SATURATED and WARNs. so if you're out here adding like it's going out of style, it'll cap out and holler at you. no cap. π
You should be using this bad boy when the memory occupied by the object might get reused to store another object β so like, consider SLAB_TYPESAFE_BY_RCU. iykyk. β¨
It provides acquire memory ordering on success, and it's assumed the caller has guaranteed the object memory to be stable (RCU, etc.). It does provide a control dependency and thereby orders future stores. see the comment on top, bestie. π
π«Ά real talk: use of this function is not recommended for the normal reference counting use case where references are taken and released one at a time. In those cases, refcount_inc_not_zero_acquire should instead be used to increment a reference count. periodt. π
β RETURN β
false if the passed refcount is 0, true otherwise. simple. clean. iconic. π
π SEE ALSO π
Kernel file ./include/linux/refcount.h
refcount_set(9)refcount_set_release(9)refcount_read(9)refcount_add_not_zero(9)refcount_add(9)refcount_inc_not_zero(9)refcount_inc_not_zero_acquire(9)refcount_inc(9)refcount_sub_and_test(9)refcount_dec_and_test(9)refcount_dec(9)
π§ and that's the whole vibe! this page lives under ./include/linux and it's stamped October 2026 β so yeah, future-dated slay. go forth and refcount responsibly, bestie ππ
π¦ 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