raw_atomic_sub(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ NAME πŸŽ€

okay so bestie, welcome to the Kernel API Manual β€” we're looking at raw_atomic_sub(9), aka atomic subtract with relaxed ordering. It's giving β€œdo one very specific thing and do it atomically,” and honestly? iconic. πŸ’…

✨ SYNOPSIS ✨

void raw_atomic_sub (int i , atomic_t *v );

that's the whole signature, no cap. Copy it exactly, spacing and all β€” we do not freestyle the C. 🫢

🌸 ARGUMENTS 🌸

  • i β€” an int: the value to subtract. simple. slay. πŸ“
  • v β€” a pointer to atomic_t. this is the atomic thing getting updated, bestie. ✨

πŸ’… DESCRIPTION πŸ’…

Atomically updates v to (v - i) with relaxed ordering. that's the whole vibe: one atomic subtraction, relaxed ordering, no extra drama. πŸ¦‹

Safe to use in noinstr code; prefer atomic_sub elsewhere.

big caveat energy: this is the raw/noinstr-friendly one, and it's relaxed ordering. If you're not in noinstr, the page says prefer atomic_sub, okay? 🫢

πŸ¦‹ RETURN πŸ¦‹

Nothing. Literally nothing, bestie β€” no return value, no sneaky little number, just the atomic subtract happening. periodt. πŸ’€βœ¨

🌈 SEE ALSO 🌈

the whole link web, and yes I'm keeping every single one β€” no skips, no β€œetc.” shenanigans. πŸ‘‘

  • Kernel file: ./include/linux/atomic/atomic-arch-fallback.h β€” the source baddie. πŸŽ€

🫢 the raw_atomic core-ish crew

πŸ’– inc/dec moment

πŸ“ and / andnot / or / xor

🧚 xchg + cmpxchg

πŸ¦‹ tests and unlesses

πŸ‘‘ raw_atomic64 core squad

🌈 raw_atomic64 inc/dec

πŸ”₯ raw_atomic64 bitwise crew

⭐ raw_atomic64 xchg + cmpxchg

πŸ’€ raw_atomic64 tests and unlesses


mwah πŸ’‹ β€” this page is straight from ./include/linux/atomic, dated October 2026, and yeah bestie, it's literally raw_atomic_sub(9). πŸŽ€βœ¨

πŸ“¦ where this page comes from