raw_atomic64...xchg_release(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… raw_atomic64_try_cmpxchg_release β€” from the Kernel API Manual (yes bestie, THE Kernel API Manual) πŸŽ€

okay so picture this: you're in kernel land, you've got a 64-bit atomic value, and you need to maybe swap it β€” but only if it still holds the value you expect. that's this function. she's the "release ordering" girlie of the try_cmpxchg family and she is lowkey iconic. let's get into it ✨


🌸 NAME 🌸

raw_atomic64_try_cmpxchg_release β€” atomic compare and exchange with release ordering πŸ¦‹


✨ SYNOPSIS ✨

bool raw_atomic64_try_cmpxchg_release (atomic64_t *v , s64 *old , s64 new );

🫢 ARGUMENTS 🫢

  • v β€” pointer to atomic64_t. this is the main character, the value we're eyeing up πŸ‘€
  • old β€” pointer to the s64 value to compare with. she's the "is it still you?" checkpoint πŸ’–
  • new β€” the s64 value to assign. the glow-up we're gonna drop in if the vibe check passes πŸ’…

πŸ’œ DESCRIPTION πŸ’œ

so here's the tea, bestie πŸ“: if (v == old), then v gets atomically updated to new with release ordering. slay, transaction complete ✨

but if it doesn't match? then v is not modified (hands off, she's not yours), old gets updated to the current value of v (so you know what you actually ran into 😭), and relaxed ordering is provided instead.

🧚 and the important caveat: this one is safe to use in noinstr code β€” that's literally her whole thing. but everywhere else, you should prefer atomic64_try_cmpxchg_release. no cap, use the fancy one unless you're in the special noinstr zone πŸ’€

πŸ”₯ RETURN πŸ”₯

  • true β€” the exchange happened, we ate πŸ‘‘
  • false β€” it didn't, better luck next time πŸ™ˆ

🌈 SEE ALSO 🌈

okay this list is long long, so buckle in β€” every single one of these is family, and they all live in the kernel file ./include/linux/atomic/atomic-arch-fallback.h πŸ“βœ¨


and that's the whole page, bestie 🫢 this one ships out of ./include/linux/atomic, dated October 2026, and the manual she lives in is raw_atomic64...xchg_release(9) πŸ’– go forth and compare-and-exchange responsibly, mwah 😘✨

πŸ“¦ where this page comes from