refcount_dec_and_test(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ refcount_dec_and_test(9) ✨

okay so this is a page from the Kernel API Manual β€” it's refcount_dec_and_test(9), and bestie, it's literally the "one down, is it zero?" girlie of the refcount family πŸ’…


🌸 NAME 🌸

refcount_dec_and_test β€” decrement a refcount and test if it is 0

πŸŽ€ SYNOPSIS πŸŽ€

bool refcount_dec_and_test (refcount_t *r );

🫢 ARGUMENTS 🫢

  • r β€” the refcount. that's it, that's the whole argument. she's the refcount we're about to knock down a peg πŸ“

πŸ’– DESCRIPTION πŸ’–

so, she's similar to atomic_dec_and_test, but with ✨consequences✨ β€” she will WARN on underflow, and she straight-up fails to decrement when the count is saturated at REFCOUNT_SATURATED. no cap, she just refuses. that's the boundary, bestie, we don't cross it πŸ™ˆ

on the ordering side she's doing the absolute most (and honestly? iconic): she provides release memory ordering, so that prior loads and stores are done before β€” and on success she provides an acquire ordering such that free must come after. so like, the free comes last, always, no cutting the line πŸ’€

πŸ”₯ RETURN πŸ”₯

  • true if the resulting refcount is 0
  • false otherwise

πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./include/linux/refcount.h β€” plus the whole refcount friend group, go say hi πŸ¦‹


ngl, if you're touching refcounts you should read the whole header. the vibes are immaculate and the saturation rules are not a joke 🌈

and that's the whole page, bestie ✨ shoutout to ./include/linux for hosting her and to October 2026 for the timestamp β€” she's dated, she's documented, she's serving main character energy, periodt πŸ’œπŸŽ€

πŸ“¦ where this page comes from