raw_atomic_cmpxchg_relaxed(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… raw_atomic_cmpxchg_relaxed(9) πŸ’…

Kernel API Manual, section 9 β€” the group chat edition ✨

okay bestie, sit down, because today's main character is a little atomic op that does comparison-and-swap energy but with the chillest ordering vibes πŸ’–


🌸 NAME 🌸

raw_atomic_cmpxchg_relaxed β€” atomic compare and exchange with relaxed ordering ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

int raw_atomic_cmpxchg_relaxed (atomic_t *v , int old , int new );

πŸŽ€ ARGUMENTS πŸŽ€

  • v β€” a pointer to atomic_t, the thing we're side-eyeing πŸ‘€
  • old β€” the int value to compare against, like the vibe check you're running
  • new β€” the int value to assign if the vibe check passes πŸ’…

✨ DESCRIPTION ✨

So here's the tea β˜• β€” if (v == old), it atomically updates v to new with relaxed ordering. Otherwise? v is not modified, and relaxed ordering is provided anyway. respectful king behavior, honestly 🫢

It's safe to use in noinstr code β€” that's its whole thing, no cap. But anywhere else, prefer atomic_cmpxchg_relaxed instead, okurrr? 😌

fr fr, noinstr is the niche here β€” if you're not in it, go hang with atomic_cmpxchg_relaxed like everyone else πŸ’€

πŸ’– RETURN πŸ’–

The original value of v β€” like, what it was before the swap. she remembers everything πŸ‘‘


🌈 SEE ALSO 🌈

Kernel file: ./include/linux/atomic/atomic-arch-fallback.h πŸ—‚οΈ

and now, the moment you've all been waiting for β€” the entire atomic family reunion πŸŽ‰ (yes, all of them, nobody's getting left out of this list):

that's the whole squad, not one of them left on read πŸ’œ


and that's the page, bestie πŸŽ€ this little icon lives in the kernel source file ./include/linux/atomic and it's stamped October 2026 β€” same energy as raw_atomic_cmpxchg_relaxed(9) forever and always βœ¨πŸ’– slay, bye! πŸ’…πŸ¦‹

πŸ“¦ where this page comes from