atomic64_cmpxchg_relaxed(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

atomic64_cmpxchg_relaxed(9) is your girl, and this is the Kernel API Manual entry for her. Bestie, gather round β€” this one is lowkey iconic πŸ’…


🌸 NAME 🌸

atomic64_cmpxchg_relaxed β€” it's an atomic compare and exchange with relaxed ordering. No cap, that's the whole name vibe ✨


✨ SYNOPSIS ✨

s64 atomic64_cmpxchg_relaxed (atomic64_t *v , s64 old , s64 new );

πŸ’… ARGUMENTS πŸ’…

  • v β€” pointer to atomic64_t. Like, a pointer to the atomic 64-bit thing you're doing the lil compare-and-exchange on 🫢
  • old β€” s64 value to compare with
  • new β€” s64 value to assign

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so picture this: if (v == old), it atomically updates v to new with relaxed ordering. If that compare does not hit, then v is not modified and relaxed ordering is provided. That's the tea β˜•

⚠️ Unsafe to use in noinstr code β€” use raw_atomic64_cmpxchg_relaxed there instead. No exceptions, bestie. This is important for real πŸ’€

πŸ“ RETURN πŸ“

It returns the original value of v. That's it. That's the return. πŸ’–


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file: ./include/linux/atomic/atomic-instrumented.h β€” and the whole extended friend group is here:


Cute lil sign-off bestie: source/version is ./include/linux/atomic, date is October 2026, and yep, the manual is atomic64_cmpxchg_relaxed(9). Periodt πŸ’œπŸŽ€

πŸ“¦ where this page comes from