refcount_ad...zero_acquire(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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


🧚 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