atomic_cmpxchg_acquire(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… atomic_cmpxchg_acquire β€” straight out of the Kernel API Manual, section 9 ✨

okay so bestie, buckle up, because this one is a tiny function with a huge friend group 🫢 It lives in the Kernel API Manual (that's the manual name, periodt πŸ’…) and it's about doing one very specific atomic thing and doing it well.


🌸 NAME

atomic_cmpxchg_acquire β€” atomic compare and exchange with acquire ordering πŸ”₯


πŸŽ€ SYNOPSIS

int atomic_cmpxchg_acquire (atomic_t *v , int old , int new );

🫢 ARGUMENTS

  • v β€” pointer to atomic_t πŸ’– the actual little variable we're messing with
  • old β€” int value to compare with πŸ‘€ the vibe check
  • new β€” int value to assign ✨ the glow-up if the vibe check passes

πŸ”₯ DESCRIPTION

So here's the tea β˜• If (v == old), it atomically updates v to new with acquire ordering. Otherwise, v is not modified and relaxed ordering is provided. No cap, that's the whole deal.

⚠️ Unsafe to use in noinstr code β€” bestie I'm begging you, use raw_atomic_cmpxchg_acquire there instead. This function is NOT it for that context 😭

πŸ‘‘ RETURN

The original value of v. that's it, that's the return, she's giving exactly one thing πŸ’€


🌈 SEE ALSO

okay so the source is the Kernel file ./include/linux/atomic/atomic-instrumented.h, and honestly the whole squad lives there too πŸ¦‹ Every single one of these is a section (9) page β€” yes, all of them, iykyk.

the atomic_t girlies (32-bit flavour) πŸ’–

  • read & set: atomic_read, atomic_read_acquire, atomic_set, atomic_set_release
  • the add-ers: atomic_add, atomic_add_return, atomic_add_return_acquire, atomic_add_return_release, atomic_add_return_relaxed, atomic_fetch_add, atomic_fetch_add_acquire, atomic_fetch_add_release, atomic_fetch_add_relaxed
  • the sub-ers: atomic_sub, atomic_sub_return, atomic_sub_return_acquire, atomic_sub_return_release, atomic_sub_return_relaxed, atomic_fetch_sub, atomic_fetch_sub_acquire, atomic_fetch_sub_release, atomic_fetch_sub_relaxed
  • the up-tickers: atomic_inc, atomic_inc_return, atomic_inc_return_acquire, atomic_inc_return_release, atomic_inc_return_relaxed, atomic_fetch_inc, atomic_fetch_inc_acquire, atomic_fetch_inc_release, atomic_fetch_inc_relaxed
  • the down-tickers: atomic_dec, atomic_dec_return, atomic_dec_return_acquire, atomic_dec_return_release, atomic_dec_return_relaxed, atomic_fetch_dec, atomic_fetch_dec_acquire, atomic_fetch_dec_release, atomic_fetch_dec_relaxed
  • the bit-twiddlers: atomic_and, atomic_fetch_and, atomic_fetch_and_acquire, atomic_fetch_and_release, atomic_fetch_and_relaxed, atomic_andnot, atomic_fetch_andnot, atomic_fetch_andnot_acquire, atomic_fetch_andnot_release, atomic_fetch_andnot_relaxed, atomic_or, atomic_fetch_or, atomic_fetch_or_acquire, atomic_fetch_or_release, atomic_fetch_or_relaxed, atomic_xor, atomic_fetch_xor, atomic_fetch_xor_acquire, atomic_fetch_xor_release, atomic_fetch_xor_relaxed
  • the swappers: atomic_xchg, atomic_xchg_acquire, atomic_xchg_release, atomic_xchg_relaxed, atomic_cmpxchg, atomic_cmpxchg_release, atomic_cmpxchg_relaxed, atomic_try_cmpxchg, atomic_try_cmpxchg_acquire, atomic_try_cmpxchg_release, atomic_try_cmpxchg_relaxed
  • the testers & the unless-ers: atomic_sub_and_test, atomic_dec_and_test, atomic_inc_and_test, atomic_add_negative, atomic_add_negative_acquire, atomic_add_negative_release, atomic_add_negative_relaxed, atomic_fetch_add_unless, atomic_add_unless, atomic_inc_not_zero, atomic_inc_unless_negative, atomic_dec_unless_positive, atomic_dec_if_positive

the atomic64_t icons (64-bit, main character energy) πŸ‘‘

  • read & set: atomic64_read, atomic64_read_acquire, atomic64_set, atomic64_set_release
  • the add-ers: atomic64_add, atomic64_add_return, atomic64_add_return_acquire, atomic64_add_return_release, atomic64_add_return_relaxed, atomic64_fetch_add, atomic64_fetch_add_acquire, atomic64_fetch_add_release, atomic64_fetch_add_relaxed
  • the sub-ers: atomic64_sub, atomic64_sub_return, atomic64_sub_return_acquire, atomic64_sub_return_release, atomic64_sub_return_relaxed, atomic64_fetch_sub, atomic64_fetch_sub_acquire, atomic64_fetch_sub_release, atomic64_fetch_sub_relaxed
  • the up-tickers: atomic64_inc, atomic64_inc_return, atomic64_inc_return_acquire, atomic64_inc_return_release, atomic64_inc_return_relaxed, atomic64_fetch_inc, atomic64_fetch_inc_acquire, atomic64_fetch_inc_release, atomic64_fetch_inc_relaxed
  • the down-tickers: atomic64_dec, atomic64_dec_return, atomic64_dec_return_acquire, atomic64_dec_return_release, atomic64_dec_return_relaxed, atomic64_fetch_dec, atomic64_fetch_dec_acquire, atomic64_fetch_dec_release, atomic64_fetch_dec_relaxed
  • the bit-twiddlers: atomic64_and, atomic64_fetch_and, atomic64_fetch_and_acquire, atomic64_fetch_and_release, atomic64_fetch_and_relaxed, atomic64_andnot, atomic64_fetch_andnot, atomic64_fetch_andnot_acquire, atomic64_fetch_andnot_release, atomic64_fetch_andnot_relaxed, atomic64_or, atomic64_fetch_or, atomic64_fetch_or_acquire, atomic64_fetch_or_release, atomic64_fetch_or_relaxed, atomic64_xor, atomic64_fetch_xor, atomic64_fetch_xor_acquire, atomic64_fetch_xor_release, atomic64_fetch_xor_relaxed
  • the swappers: atomic64_xchg, atomic64_xchg_acquire, atomic64_xchg_release, atomic64_xchg_relaxed, atomic64_cmpxchg, atomic64_cmpxchg_acquire, atomic64_cmpxchg_release, atomic64_cmpxchg_relaxed, atomic64_try_cmpxchg, atomic64_try_cmpxchg_acquire, atomic64_try_cmpxchg_release, atomic64_try_cmpxchg_relaxed
  • the testers & the unless-ers: atomic64_sub_and_test, atomic64_dec_and_test, atomic64_inc_and_test, atomic64_add_negative, atomic64_add_negative_acquire, atomic64_add_negative_release, atomic64_add_negative_relaxed, atomic64_fetch_add_unless, atomic64_add_unless, atomic64_inc_not_zero, atomic64_inc_unless_negative, atomic64_dec_unless_positive, atomic64_dec_if_positive

the atomic_long legends (long live the long) 🌈

  • read & set: atomic_long_read, atomic_long_read_acquire, atomic_long_set, atomic_long_set_release
  • the add-ers: atomic_long_add, atomic_long_add_return, atomic_long_add_return_acquire, atomic_long_add_return_release, atomic_long_add_return_relaxed, atomic_long_fetch_add, atomic_long_fetch_add_acquire, atomic_long_fetch_add_release, atomic_long_fetch_add_relaxed
  • the sub-ers: atomic_long_sub, atomic_long_sub_return, atomic_long_sub_return_acquire, atomic_long_sub_return_release, atomic_long_sub_return_relaxed, atomic_long_fetch_sub, atomic_long_fetch_sub_acquire, atomic_long_fetch_sub_release, atomic_long_fetch_sub_relaxed
  • the up-tickers: atomic_long_inc, atomic_long_inc_return, atomic_long_inc_return_acquire, atomic_long_inc_return_release, atomic_long_inc_return_relaxed, atomic_long_fetch_inc, atomic_long_fetch_inc_acquire, atomic_long_fetch_inc_release, atomic_long_fetch_inc_relaxed
  • the down-tickers: atomic_long_dec, atomic_long_dec_return, atomic_long_dec_return_acquire, atomic_long_dec_return_release, atomic_long_dec_return_relaxed, atomic_long_fetch_dec, atomic_long_fetch_dec_acquire, atomic_long_fetch_dec_release, atomic_long_fetch_dec_relaxed
  • the bit-twiddlers: atomic_long_and, atomic_long_fetch_and, atomic_long_fetch_and_acquire, atomic_long_fetch_and_release, atomic_long_fetch_and_relaxed, atomic_long_andnot, atomic_long_fetch_andnot, atomic_long_fetch_andnot_acquire, atomic_long_fetch_andnot_release, atomic_long_fetch_andnot_relaxed, atomic_long_or, atomic_long_fetch_or, atomic_long_fetch_or_acquire, atomic_long_fetch_or_release, atomic_long_fetch_or_relaxed, atomic_long_xor, atomic_long_fetch_xor, atomic_long_fetch_xor_acquire, atomic_long_fetch_xor_release, atomic_long_fetch_xor_relaxed
  • the swappers: atomic_long_xchg, atomic_long_xchg_acquire, atomic_long_xchg_release, atomic_long_xchg_relaxed, atomic_long_cmpxchg, atomic_long_cmpxchg_acquire, atomic_long_cmpxchg_release, atomic_long_cmpxchg_relaxed, atomic_long_try_cmpxchg, atomic_long_try_cmpxchg_acquire, atomic_long_try_cmpxchg_release, atomic_long_try_cmpxchg_relaxed
  • the testers & the unless-ers: atomic_long_sub_and_test, atomic_long_dec_and_test, atomic_long_inc_and_test, atomic_long_add_negative, atomic_long_add_negative_acquire, atomic_long_add_negative_release, atomic_long_add_negative_relaxed, atomic_long_fetch_add_unless, atomic_long_add_unless, atomic_long_inc_not_zero, atomic_long_inc_unless_negative, atomic_long_dec_unless_positive, atomic_long_dec_if_positive

that's the whole page bestie, love that for us πŸ’œ


mwah πŸ’‹ this one came from ./include/linux/atomic, dated October 2026, and it's filed under atomic_cmpxchg_acquire(9) β€” go be atomic, stay iconic πŸŽ€βœ¨

πŸ“¦ where this page comes from