atomic_dec_return(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ atomic_dec_return(9) πŸŽ€

okay bestie, welcome to the atomic_dec_return(9) page β€” it lives in the Kernel API Manual and it's lowkey one of the most useful little functions in the atomic family. it's giving "shrink the counter, but make it thread-safe" energy. let's get into it πŸ’…


✨ NAME ✨

atomic_dec_return β€” atomic decrement with full ordering. that's it, that's the whole vibe: minus one, done atomically, and everything around it properly ordered. no cap πŸ”₯


🌸 SYNOPSIS 🌸

int atomic_dec_return (atomic_t *v );

(yes, there's a space before that closing paren. that's just how the man page prints it, don't @ me 🫢)


πŸ¦‹ ARGUMENTS πŸ¦‹

  • v β€” pointer to atomic_t. you're handing over a pointer to the little atomic counter, and it's gonna get decremented. main character energy for v, honestly πŸ‘‘

πŸ’– DESCRIPTION πŸ’–

Atomically updates v to (v - 1) with full ordering.

so like. the decrement happens all at once, nobody can catch it mid-subtraction, and the full ordering means the memory barriers are doing their thing around it. iconic behavior ✨

⚠️ Unsafe to use in noinstr code β€” use raw_atomic_dec_return there instead. not me warning you twice: do NOT use this one in noinstr code, bestie. it's literally unsafe there. use raw_atomic_dec_return and everyone stays happy πŸ’€

🌈 RETURN 🌈

The updated value of v β€” i.e. the value after the decrement. so you get the fresh new number back, not the old one. obsessed πŸ“


πŸ‘‘ SEE ALSO πŸ‘‘

buckle up, this list is a whole mood board of atomic operations. every single one of these is a real page, fr fr 🧚

iykyk, that's the whole atomic cinematic universe right there 😭πŸ”₯


okayyy so that's the page!! this gem came out of ./include/linux/atomic and it's dated October 2026 β€” so it's fresh, it's documented, and it's decrementing with full ordering. go forth and atomic_dec_return responsibly, bestie πŸ«ΆπŸ’–βœ¨

πŸ“¦ where this page comes from