atomic_sub_return_relaxed(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… atomic_sub_return_relaxed πŸ’…

okay so you're in the Kernel API Manual, bestie, and we're talking about one very specific little atomic function. buckle up πŸŽ€


🌸 NAME 🌸

atomic_sub_return_relaxed β€” atomic subtract with relaxed ordering ✨


✨ SYNOPSIS ✨

int atomic_sub_return_relaxed (int i , atomic_t *v );

🫢 ARGUMENTS 🫢

  • i β€” an int, and it's the value you're subtracting. that's it, that's the number πŸ’–
  • v β€” a pointer to an atomic_t. this is the thing getting updated, no cap πŸ¦‹

πŸ’– DESCRIPTION πŸ’–

So the whole vibe: this atomically updates v to (v - i) with relaxed ordering. atomic means nobody can catch it mid-subtract, it just happens, periodt πŸ”₯

⚠️ Unsafe to use in noinstr code β€” like, genuinely do not. if you're in noinstr code, use raw_atomic_sub_return_relaxed there instead. this is a real caveat, not a drill, bestie πŸ’€

πŸŽ€ RETURN πŸŽ€

It gives you back the updated value of v β€” the value after the subtraction, not the old one. that's the whole point, iykyk 😌


🌈 SEE ALSO 🌈

Kernel file ./include/linux/atomic/atomic-instrumented.h β€” that's where the magic lives 🧚 and here's the whole extended friend group, literally everyone:

the atomic_ girlies β€” reads, sets, adds

the atomic_ sub crew

inc/dec energy

bitwise besties

swaps and compare-swaps

tests, negatives, and the "unless" squad

🌟 the 64-bit edition 🌟

πŸ¦‹ the long edition πŸ¦‹


and that's the whole page, bestie πŸ’œ go subtract something atomically and remember: relaxed ordering, not relaxed attitude about noinstr code 😀

source: ./include/linux/atomic β€” dated October 2026 πŸ—“οΈ mwah πŸ’‹

πŸ“¦ where this page comes from