atomic_try_cmpxchg_release(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ atomic_try_cmpxchg_release(9) β€” the Kernel API Manual glow-up πŸ¦‹

okay so bestie, welcome to the <pink>Kernel API Manual</pink> entry for atomic_try_cmpxchg_release, and no cap, this one is kind of a baddie. it does an atomic compare-and-exchange, but with release ordering, which is the whole vibe. let's get into it πŸ’…


✨ NAME ✨

atomic_try_cmpxchg_release β€” atomic compare and exchange with release ordering πŸŽ€


🌸 SYNOPSIS 🌸

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

like, that's the whole signature. short. iconic. to the point. πŸ‘‘


🫢 ARGUMENTS 🫢

  • v β€” pointer to atomic_t. this is the atomic thing we're looking at, bestie 🧚
  • old β€” pointer to an int value to compare with. yes, it's a pointer, she's not just a value, she's a whole address πŸ”₯
  • new β€” the int value to assign. the glow-up value, if you will ✨

πŸ’– DESCRIPTION πŸ’–

so here's the tea. if (v == old), then it atomically updates v to new with release ordering. periodt. πŸ’…

otherwise? v is not modified, old gets updated to the current value of v, and relaxed ordering is provided. so it's giving "we didn't match, but here's the actual value, you're welcome" 😭

⚠️ okay real talk, this is unsafe to use in noinstr code. use raw_atomic_try_cmpxchg_release there instead. don't be the main character who ignores this, fr fr πŸ’€

πŸ‘‘ RETURN πŸ‘‘

  • true β€” if the exchange occurred πŸŽ‰
  • false β€” otherwise πŸ™ˆ

that's it. that's the answer. boolean baddie energy ⭐


πŸ’œ SEE ALSO πŸ’œ

the kernel file is ./include/linux/atomic/atomic-instrumented.h, and honestly the squad it rolls with is huge. like, everybody's here. iykyk 🌈

the atomic_* girlies:

the atomic64_* crew, living their 64-bit truth:

and the atomic_long_* icons, long may they reign:

like… that's the whole family reunion and everybody ate πŸ’€πŸ“


and that's the page, bestie! this little masterpiece lives over at ./include/linux/atomic, it's dated October 2026, and it's filed under atomic_try_cmpxchg_release(9) β€” go off, you atomic icon πŸ‘‘πŸ’–βœ¨

πŸ“¦ where this page comes from