refcount_set_release(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ refcount_set_release(9) πŸ¦‹

okay so bestie, we're in the Kernel API Manual today and this one is a baddie. it's refcount_set_release, and it's giving "i set a refcount but make it ✨ordered✨". stay with me, it's actually so good.


🌸 NAME 🌸

refcount_set_release β€” set a refcount's value with release ordering πŸ’…


⭐ SYNOPSIS ⭐

void refcount_set_release (refcount_t *r , int n );

like, that's it. that's the whole signature. iconic.


πŸŽ€ ARGUMENTS πŸŽ€

  • r β€” the refcount. your girl. the actual refcount_t we're messing with 🫢
  • n β€” value to which the refcount will be set. yes, the refcount will be set to n. that's the vibe.

πŸ’– DESCRIPTION πŸ’–

okay so listen. highkey this one has a whole situation attached to it.

This function should be used when memory occupied by the object might be reused to store another object β€” consider SLAB_TYPESAFE_BY_RCU. like, the memory's getting recycled, bestie, and we need to be normal about it. πŸ™ˆ

It provides release memory ordering, which will order previous memory operations against this store. This ensures all updates to this object are visible once the refcount is set and stale values from the object previously occupying this memory are overwritten with new ones. no cap β€” the stale stuff gets yeeted, the new stuff is visible, periodt. πŸ”₯

This function should be called only after the new object is fully initialized. fr fr. do not skip this step, do not pass go, do not collect $200. πŸ’€

After this call the object should be considered visible to other tasks even if it was not yet added into an object collection normally used to discover it. which is like, kind of unhinged but also correct β€” the way that other tasks might have discovered the object previously occupying the same memory, and after memory reuse they can succeed in taking refcount to the new object and start using it. so yeah. it's visible. main character energy, whether you added it to the collection or not. πŸ‘‘


🧚 SEE ALSO 🧚

Kernel file ./include/linux/refcount.h β€” aka the mothership β€” plus the whole refcount friend group, all linked up:


🌈 and that's the whole page, bestie! this one ships out of ./include/linux, dated October 2026 β€” so like, future core, slay. mwah πŸ’‹ go set some refcounts responsibly πŸ“

πŸ“¦ where this page comes from