refcount_inc(9)
π refcount_inc β bestie, we're incrementing a refcount
okay so first things first, this is a page from the Kernel API Manual (yes, the kernel has a whole manual, she's fancy like that β¨), and today's main character is refcount_inc.
π NAME π
refcount_inc β increment a refcount. that's it. that's the vibe. π
β¨ SYNOPSIS β¨
void refcount_inc (refcount_t *r );
like literally that's the whole signature, she's compact and she knows it π«Ά
πΈ ARGUMENTS πΈ
rβ the refcount to increment π this is the girl you're bumping up, no cap
π¦ DESCRIPTION π¦
okay so picture atomic_inc, right? refcount_inc is giving similar energy, but she's got boundaries. instead of just going up forever, she will saturate at REFCOUNT_SATURATED and hit you with a WARN. yeah. she will literally warn you. consider that your vibe check failing π₯
she provides no memory ordering β none, zero, nada. the assumption is that the caller already has a reference on the object, so like, you already had the key to the group chat, this isn't the moment we're doing barriers, bestie π§
and the big one, the thing you do NOT wanna ignore: she will WARN if the refcount is 0, because a count of zero represents a possible use-after-free condition. that's the scary one π that's the "oh no bestie what did we do" moment. 0 means the object may already be gone, and touching it is giving "walking into a room after the party ended" energy π so fr fr, don't be that person.
π SEE ALSO π
okay so there's a whole friend group here, all hanging out in the kernel file ./include/linux/refcount.h π go say hi to:
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_not_zero_acquire(9)refcount_sub_and_test(9)refcount_dec_and_test(9)refcount_dec(9)
like literally the whole squad, iykyk π
ngl this one's short but she's important. saturating, warning, no memory ordering, and a very loud "please don't call me on a zero" π©·
and that's the page!! brought to you by the good people at ./include/linux, dated October 2026 β mwah, go forth and 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