raw_atomic64...xchg_relaxed(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 raw_atomic64...xchg_relaxed(9) β€” Kernel API Manual 🌸

okay bestie, buckle up, because this is one of those pages where the title up top and the NAME down below are doing a little outfit-change moment πŸ’… β€” the page header says raw_atomic64...xchg_relaxed(9) in the Kernel API Manual, and the NAME section is all about raw_atomic64_try_cmpxchg_relaxed. Same energy, different name tag. Let's go 🫢


✨ NAME ✨

raw_atomic64_try_cmpxchg_relaxed β€” atomic compare and exchange with relaxed ordering. that's it. that's the tweet πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

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

like, yes she returns a bool, and yes she takes three things. keep reading, we'll introduce everyone 🌸


πŸ¦‹ ARGUMENTS πŸ¦‹

  • v β€” pointer to atomic64_t. this is the main character, the value we're all gathered here for πŸ‘‘
  • old β€” pointer to an s64 value to compare with. not the value itself, bestie, a pointer to it. she's indirect like that πŸŽ€
  • new β€” an s64 value to assign. this is the glow-up we're trying to install ✨

πŸ’œ DESCRIPTION πŸ’œ

okay so here's the whole plot πŸ™ˆ

if (v == old), then v gets atomically updated to new with relaxed ordering. slay, exchange complete πŸ’…

otherwise? v is not modified β€” she stays exactly as she is 🧚 β€” and old is updated to the current value of v, and relaxed ordering is provided. so like, even when it doesn't work out, you still walk away with info. honestly? character development ✨

🫢 safety note, no cap: this one is safe to use in noinstr code. but everywhere else, prefer atomic64_try_cmpxchg_relaxed instead. it's giving "the raw version is for the special occasions only" πŸ’€

πŸ”₯ RETURN πŸ”₯

  • true β€” the exchange happened, we ate, periodt πŸ’…
  • false β€” the exchange did not happen. not me 😭

🌈 SEE ALSO 🌈

first up, the kernel file herself, located at:

./include/linux/atomic/atomic-arch-fallback.h

and now the friend group πŸ’– (in order, because we respect the timeline):

raw_atomic_read(9), raw_atomic_read_acquire(9), raw_atomic_set(9), raw_atomic_set_release(9), raw_atomic_add(9), raw_atomic_add_return(9), raw_atomic_add_return_acquire(9), raw_atomic_add_return_release(9), raw_atomic_add_return_relaxed(9), raw_atomic_fetch_add(9), raw_atomic_fetch_add_acquire(9), raw_atomic_fetch_add_release(9), raw_atomic_fetch_add_relaxed(9), raw_atomic_sub(9), raw_atomic_sub_return(9), raw_atomic_sub_return_acquire(9), raw_atomic_sub_return_release(9), raw_atomic_sub_return_relaxed(9), raw_atomic_fetch_sub(9), raw_atomic_fetch_sub_acquire(9), raw_atomic_fetch_sub_release(9), raw_atomic_fetch_sub_relaxed(9), raw_atomic_inc(9), raw_atomic_inc_return(9), raw_atomic_inc_return_acquire(9), raw_atomic_inc_return_release(9), raw_atomic_inc_return_relaxed(9), raw_atomic_fetch_inc(9), raw_atomic_fetch_inc_acquire(9), raw_atomic_fetch_inc_release(9), raw_atomic_fetch_inc_relaxed(9), raw_atomic_dec(9), raw_atomic_dec_return(9), raw_atomic_dec_return_acquire(9), raw_atomic_dec_return_release(9), raw_atomic_dec_return_relaxed(9), raw_atomic_fetch_dec(9), raw_atomic_fetch_dec_acquire(9), raw_atomic_fetch_dec_release(9), raw_atomic_fetch_dec_relaxed(9), raw_atomic_and(9), raw_atomic_fetch_and(9), raw_atomic_fetch_and_acquire(9), raw_atomic_fetch_and_release(9), raw_atomic_fetch_and_relaxed(9), raw_atomic_andnot(9), raw_atomic_fetch_andnot(9), raw_atomic_fetch_andnot_acquire(9), raw_atomic_fetch_andnot_release(9), raw_atomic_fetch_andnot_relaxed(9), raw_atomic_or(9), raw_atomic_fetch_or(9), raw_atomic_fetch_or_acquire(9), raw_atomic_fetch_or_release(9), raw_atomic_fetch_or_relaxed(9), raw_atomic_xor(9), raw_atomic_fetch_xor(9), raw_atomic_fetch_xor_acquire(9), raw_atomic_fetch_xor_release(9), raw_atomic_fetch_xor_relaxed(9), raw_atomic_xchg(9), raw_atomic_xchg_acquire(9), raw_atomic_xchg_release(9), raw_atomic_xchg_relaxed(9), raw_atomic_cmpxchg(9), raw_atomic_cmpxchg_acquire(9), raw_atomic_cmpxchg_release(9), raw_atomic_cmpxchg_relaxed(9), raw_atomic_try_cmpxchg(9), raw_atomic_try_cmpxchg_acquire(9), raw_atomic_try_cmpxchg_release(9), raw_atomic_try_cmpxchg_relaxed(9), raw_atomic_sub_and_test(9), raw_atomic_dec_and_test(9), raw_atomic_inc_and_test(9), raw_atomic_add_negative(9), raw_atomic_add_negative_acquire(9), raw_atomic_add_negative_release(9), raw_atomic_add_negative_relaxed(9), raw_atomic_fetch_add_unless(9), raw_atomic_add_unless(9), raw_atomic_inc_not_zero(9), raw_atomic_inc_unless_negative(9), raw_atomic_dec_unless_positive(9), raw_atomic_dec_if_positive(9) 🌸

and then the 64-bit girlies take over, same order, same energy πŸ¦‹:

raw_atomic64_read(9), raw_atomic64_read_acquire(9), raw_atomic64_set(9), raw_atomic64_set_release(9), raw_atomic64_add(9), raw_atomic64_add_return(9), raw_atomic64_add_return_acquire(9), raw_atomic64_add_return_release(9), raw_atomic64_add_return_relaxed(9), raw_atomic64_fetch_add(9), raw_atomic64_fetch_add_acquire(9), raw_atomic64_fetch_add_release(9), raw_atomic64_fetch_add_relaxed(9), raw_atomic64_sub(9), raw_atomic64_sub_return(9), raw_atomic64_sub_return_acquire(9), raw_atomic64_sub_return_release(9), raw_atomic64_sub_return_relaxed(9), raw_atomic64_fetch_sub(9), raw_atomic64_fetch_sub_acquire(9), raw_atomic64_fetch_sub_release(9), raw_atomic64_fetch_sub_relaxed(9), raw_atomic64_inc(9), raw_atomic64_inc_return(9), raw_atomic64_inc_return_acquire(9), raw_atomic64_inc_return_release(9), raw_atomic64_inc_return_relaxed(9), raw_atomic64_fetch_inc(9), raw_atomic64_fetch_inc_acquire(9), raw_atomic64_fetch_inc_release(9), raw_atomic64_fetch_inc_relaxed(9), raw_atomic64_dec(9), raw_atomic64_dec_return(9), raw_atomic64_dec_return_acquire(9), raw_atomic64_dec_return_release(9), raw_atomic64_dec_return_relaxed(9), raw_atomic64_fetch_dec(9), raw_atomic64_fetch_dec_acquire(9), raw_atomic64_fetch_dec_release(9), raw_atomic64_fetch_dec_relaxed(9), raw_atomic64_and(9), raw_atomic64_fetch_and(9), raw_atomic64_fetch_and_acquire(9), raw_atomic64_fetch_and_release(9), raw_atomic64_fetch_and_relaxed(9), raw_atomic64_andnot(9), raw_atomic64_fetch_andnot(9), raw_atomic64_fetch_andnot_acquire(9), raw_atomic64_fetch_andnot_release(9), raw_atomic64_fetch_andnot_relaxed(9), raw_atomic64_or(9), raw_atomic64_fetch_or(9), raw_atomic64_fetch_or_acquire(9), raw_atomic64_fetch_or_release(9), raw_atomic64_fetch_or_relaxed(9), raw_atomic64_xor(9), raw_atomic64_fetch_xor(9), raw_atomic64_fetch_xor_acquire(9), raw_atomic64_fetch_xor_release(9), raw_atomic64_fetch_xor_relaxed(9), raw_atomic64_xchg(9), raw_atomic64_xchg_acquire(9), raw_atomic64_xchg_release(9), raw_atomic64_xchg_relaxed(9), raw_atomic64_cmpxchg(9), raw_atomic64_cmpxchg_acquire(9), raw_atomic64_cmpxchg_release(9), raw_atomic64_cmpxchg_relaxed(9), raw_atomic64_try_cmpxchg(9), raw_atomic64_try_cmpxchg_acquire(9), raw_atomic64_try_cmpxchg_release(9), raw_atomic64_sub_and_test(9), raw_atomic64_dec_and_test(9), raw_atomic64_inc_and_test(9), raw_atomic64_add_negative(9), raw_atomic64_add_negative_acquire(9), raw_atomic64_add_negative_release(9), raw_atomic64_add_negative_relaxed(9), raw_atomic64_fetch_add_unless(9), raw_atomic64_add_unless(9), raw_atomic64_inc_not_zero(9), raw_atomic64_inc_unless_negative(9), raw_atomic64_dec_unless_positive(9), raw_atomic64_dec_if_positive(9) πŸ’œ


🧚 oh and one more little thing β€” even though raw_atomic_try_cmpxchg_relaxed(9) isn't in the SEE ALSO list, it does show up in the DESCRIPTION telling you to prefer it elsewhere. we love a plot twist that's actually foreshadowing ✨

okay bye bestie, go forth and exchange atomically πŸ’… and remember where this page lives β€” ./include/linux/atomic β€” dated October 2026, filed under raw_atomic64...xchg_relaxed(9). she's iconic, she's documented, she's yours πŸŽ€βœ¨πŸ«Ά

πŸ“¦ where this page comes from