atomic_long...xchg_release(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… atomic_long_try_cmpxchg_release(9) πŸ’…

okay so bestie, this is a page from the Kernel API Manual, and it's about exactly one ✨iconic✨ little function. Buckle up, it's giving concurrency realness 🌸


πŸŽ€ NAME πŸŽ€

atomic_long_try_cmpxchg_release β€” atomic compare and exchange with release ordering


✨ SYNOPSIS ✨

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

🫢 ARGUMENTS 🫢

  • v β€” pointer to atomic_long_t. this is the main character we're operating on πŸ‘‘
  • old β€” pointer to long value to compare with. it's doing double duty, more on that below πŸ‘€
  • new β€” long value to assign. the new era, the rebrand πŸ’–

πŸ’– DESCRIPTION πŸ’–

Okay so here's the vibe check: if (v == old), then v gets atomically updated to new with release ordering. slay πŸ’…

Otherwise? v is not modified, old is updated to the current value of v, and relaxed ordering is provided. so old is lowkey a little messenger that comes back with the actual current value. iykyk πŸ¦‹

⚠️ Unsafe to use in noinstr code β€” use raw_atomic_long_try_cmpxchg_release there instead. no cap, that one's the raw version for a reason 😭

πŸ”₯ RETURN πŸ”₯

true if the exchange occurred, false otherwise. simple as that, periodt ✨


🌈 SEE ALSO 🌈

Kernel file ./include/linux/atomic/atomic-instrumented.h β€” and literally the entire atomic extended universe lives in there, bestie 🧚 here's the full guest list:


anyway, that's the whole page bestie πŸ’œ it lives in ./include/linux/atomic, dated October 2026, and it's brought to you by the Kernel API Manual β€” atomic_long...xchg_release(9). go forth and compare-and-exchange responsibly 🫢✨

πŸ“¦ where this page comes from