atomic64_dec_if_positive(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… atomic64_dec_if_positive β€” Kernel API Manual

okay so bestie, welcome to the Kernel API Manual β€” this one's about atomic64_dec_if_positive, and honestly it's such a clean little function. like it knows exactly what it wants and does it atomically. we love a decisive icon πŸŽ€


✨ NAME ✨

atomic64_dec_if_positive β€” atomic decrement if positive with full ordering

like the name literally spells it out: it's atomic, it decrements, and it only does the thing if the value is positive. full ordering included, no extra charge πŸ¦‹


⭐ SYNOPSIS ⭐

s64 atomic64_dec_if_positive (atomic64_t *v );

that's it. that's the whole signature. she's short, she's sweet, she takes one pointer πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • v β€” pointer to atomic64_t. yes bestie, a pointer. you're handing her the address of your atomic 64-bit value and she'll take it from there 🫢

πŸ’– DESCRIPTION πŸ’–

okay so here's the vibe:

if (v > 0), it atomically updates v to (v - 1) with full ordering. like, fully ordered. she's not cutting corners, she's not rushing, she's doing the memory ordering properly 🧚✨

otherwise β€” meaning v isn't greater than zero β€” v is not modified and relaxed ordering is provided. no changes, no drama, just a chill relaxed vibe.

🚨 real talk though: this is unsafe to use in noinstr code. if you're in noinstr land, use raw_atomic64_dec_if_positive there instead. iykyk. don't be the person who ignores this, ok? 😭

πŸ‘‘ RETURN πŸ‘‘

the old value of (v - 1), regardless of whether v was updated.

read that again β€” regardless. whether she did the decrement or not, you get the old value of (v - 1) back. so the return is consistent no matter which branch you landed in. periodt 🌸


🌈 SEE ALSO 🌈

the full crew, all listed out, no one left behind. yes this is the entire list, yes i checked, yes it's a lot, and yes it ate πŸ’€πŸ”₯

kernel file: ./include/linux/atomic/atomic-instrumented.h

the atomic_* girlies:

the atomic64_* besties (our main character's whole family):

the atomic_long_* crowd:


and that's the whole page bestie, you're officially caught up πŸ’–

sign-off time πŸŽ€ this one lives in ./include/linux/atomic, it's dated October 2026, and it's filed under atomic64_dec_if_positive(9) β€” go be atomic, stay positive (unless you're a counter, in which case, decrement responsibly) πŸ¦‹βœ¨πŸ’œ

πŸ“¦ where this page comes from