refcount_add(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… refcount_add β€” the Kernel API Manual page you actually want to read ✨

okay bestie, welcome to the Kernel API Manual entry for refcount_add(9) β€” she's a refcount girly and she has thoughts. πŸŽ€


🌸 NAME 🌸

refcount_add β€” literally just adds a value to a refcount. that's the whole job. no cap. πŸ’–


✨ SYNOPSIS ✨

void refcount_add (int i , refcount_t *r );

look at her. two arguments. zero drama (mostly). πŸ¦‹


🫢 ARGUMENTS 🫢

  • i β€” the value you're adding to the refcount, aka the amount, aka the vibe you're contributing πŸ’«
  • r β€” the refcount itself, the main character, the thing getting incremented πŸ‘‘

πŸ’… DESCRIPTION πŸ’…

okay so. she's similar to atomic_add, but β€” and this is the tea β€” she will saturate at REFCOUNT_SATURATED and WARN. so if you try to push her past the limit she doesn't just wrap around like some chaotic unhinged function, she stops, saturates, and hollers at you. πŸ—£οΈπŸ”₯

she provides no memory ordering. nope, zero, none. it is assumed that the caller has guaranteed the object memory to be stable (RCU, etc.). so like, that's on you, bestie, not her. πŸ™ˆ but she does provide a control dependency and thereby orders future stores. see the comment on top. iykyk. ⭐

now for the part where i have to be a responsible friend: use of this function is not recommended for the normal reference counting use case in which references are taken and released one at a time. 😭 in those cases, refcount_inc, or one of its variants, should instead be used to increment a reference count. like she's iconic but she's not the one for that job, fr fr. 🧚

lowkey a warning but a cute one: saturating and WARNing is the behaviour, and no memory ordering is provided β€” don't come for her when you needed ordering, she never promised that πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹

kernel file ./include/linux/refcount.h, plus the whole squad:

the whole group chat, together again πŸ«ΆπŸ’œ


and that's the page, bestie!! 🌈 she lives in ./include/linux and this lil drop is from October 2026 β€” mwah, slay, periodt, go forth and refcount responsibly πŸ’–πŸŽ€βœ¨

πŸ“¦ where this page comes from