atomic_long...xchg_relaxed(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… NAME πŸ’…

okay so this page is titled atomic_long...xchg_relaxed(9) (yes, abbreviated, it's giving mystery πŸ’€) but the actual star of the show is atomic_long_try_cmpxchg_relaxed β€” an atomic compare and exchange with relaxed ordering. bestie, it's a compare-and-swap, but chill about it. 🫢


✨ SYNOPSIS ✨

bool atomic_long_try_cmpxchg_relaxed (atomic_long_t *v , long *old ,
long new );

like, that's the whole signature. no cap. ✨


πŸŽ€ ARGUMENTS πŸŽ€

  • v β€” pointer to atomic_long_t β€” the vibe (and the value) lives here πŸ’–
  • old β€” pointer to long value to compare with β€” the "are you the one I'm thinking of?" check πŸ¦‹
  • new β€” long value to assign β€” the glow-up you're swapping in 🌸

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea β˜•: if (v == old), it atomically updates v to new with relaxed ordering. slay. that's the whole point. πŸ”₯

otherwise? v is not modified 😭 β€” instead, old gets updated to the current value of v, and relaxed ordering is provided. so it's like, "oops, here's what's actually there, bestie, sorry for the mix-up". πŸ™ˆ

⚠️ heads up fr fr: this is unsafe to use in noinstr code. if you're in noinstr land, use raw_atomic_long_try_cmpxchg_relaxed there instead. don't be that girl. πŸ’…

🌸 RETURN 🌸

  • true if the exchange occurred πŸ‘‘ (you ate, congrats)
  • false otherwise πŸ’€ (no exchange, but old got a lil update)

🫢 SEE ALSO 🫢

the kernel file is ./include/linux/atomic/atomic-instrumented.h, and it is one hundred percent holding the entire friend group of atomics. prepare yourself, this list is a long one but every single one of them is here 🧚:


✨ and that's the whole page, bestie ✨ this lil gem comes from the source file ./include/linux/atomic, dated October 2026, and it signs off as atomic_long...xchg_relaxed(9) β€” go forth and compare-and-exchange responsibly, ily πŸ’œπŸ¦‹

πŸ“¦ where this page comes from