refcount_dec_and_test(9)
β¨ 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 π₯
trueif the resulting refcount is0falseotherwise
π SEE ALSO π
Kernel file ./include/linux/refcount.h β plus the whole refcount friend group, go say hi π¦
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_inc(9)refcount_sub_and_test(9)refcount_dec(9)
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
- 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