atomic_try_cmpxchg_acquire(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… NAME πŸ’…

Hiii bestie πŸ’– welcome to atomic_try_cmpxchg_acquire(9) from the Kernel API Manual. This one is literally atomic_try_cmpxchg_acquire β€” atomic compare and exchange with acquire ordering. Periodt. ✨

✨ SYNOPSIS ✨

bool atomic_try_cmpxchg_acquire (atomic_t *v , int *old , int new );

πŸŽ€ ARGUMENTS πŸŽ€

  • v β€” pointer to atomic_t.
  • old β€” pointer to int value to compare with.
  • new β€” int value to assign.

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so here’s the vibe: if (v == old), it atomically updates v to new with acquire ordering. Slay. ✨

Otherwise, v is not modified, old is updated to the current value of v, and relaxed ordering is provided. No cap.

🚨 Real talk: this is unsafe to use in noinstr code. Use raw_atomic_try_cmpxchg_acquire there instead, bestie.

🌸 RETURN 🌸

It returns true if the exchange occurred, and false otherwise. Simple as that. πŸ’…

πŸ’– SEE ALSO πŸ’–

Kernel file: ./include/linux/atomic/atomic-instrumented.h β€” and here’s the whole atomic friend group chat, all present and accounted for:


Catch u later, bestie 🫢 β€” this page is from source/version ./include/linux/atomic, dated October 2026, and it’s the atomic_try_cmpxchg_acquire(9) page. πŸ’–

πŸ“¦ where this page comes from