raw_atomic_...xchg_acquire(9)
π
raw_atomic_long_cmpxchg_acquire π
okay bestie come closer β this is a page from the Kernel API Manual, and the header on it is literally raw_atomic_...xchg_acquire(9) because somebody's terminal was too narrow to fit the whole name π (the real star here is raw_atomic_long_cmpxchg_acquire, don't let the truncated header gaslight you). it's a kernel function, it's doing atomic stuff, and ngl it's kind of iconic.
π NAME π
raw_atomic_long_cmpxchg_acquire β atomic compare and exchange, but make it acquire-ordered. that's the whole vibe. no cap.
β¨ SYNOPSIS β¨
long raw_atomic_long_cmpxchg_acquire (atomic_long_t *v , long old , long new );
that's it. that's the whole signature. three args, one long back. slay.
π¦ ARGUMENTS π¦
vβ pointer to anatomic_long_t. it's the thing getting compared, and maybe exchanged. main character energy tbh.oldβ thelongvalue you're comparing against. like, "isvthis one? π"newβ thelongvalue you wanna assign if the comparison goes your way. the glow-up value.
π DESCRIPTION π
okay so here's the tea π΅: if (v == old), then it atomically updates v to new with acquire ordering. literally all in one go, no one else gets to peek in between. otherwise, v is not modified at all, and you get relaxed ordering instead. so like... if the comparison flops, no changes, and the ordering vibe is chill.
it's safe to use in noinstr code π«Ά β but everywhere else, prefer atomic_long_cmpxchg_acquire. that's the recommendation, fr fr. not a warning, just the polite suggestion.
so: match βvbecomesnew, acquire ordering, atomically. no match βvstays exactly as it was, relaxed ordering. no side quests, no surprises. π
πΈ RETURN πΈ
the original value of v β i.e. what v was before any of this went down. so you always get the receipts on what it used to be, whether the swap happened or not. π₯
π SEE ALSO π
first off, the source of truth lives in the kernel file ./include/linux/atomic/atomic-long.h β that's the mothership, go visit her. π§
and here's the whole friend group, because this function has so many siblings and honestly they all ate:
π read & set girlies
raw_atomic_long_read(9)raw_atomic_long_read_acquire(9)raw_atomic_long_set(9)raw_atomic_long_set_release(9)
π add crew
raw_atomic_long_add(9)raw_atomic_long_add_return(9)raw_atomic_long_add_return_acquire(9)raw_atomic_long_add_return_release(9)raw_atomic_long_add_return_relaxed(9)raw_atomic_long_fetch_add(9)raw_atomic_long_fetch_add_acquire(9)raw_atomic_long_fetch_add_release(9)raw_atomic_long_fetch_add_relaxed(9)
π sub squad
raw_atomic_long_sub(9)raw_atomic_long_sub_return(9)raw_atomic_long_sub_return_acquire(9)raw_atomic_long_sub_return_release(9)raw_atomic_long_sub_return_relaxed(9)raw_atomic_long_fetch_sub(9)raw_atomic_long_fetch_sub_acquire(9)raw_atomic_long_fetch_sub_release(9)raw_atomic_long_fetch_sub_relaxed(9)
π¦ inc besties
raw_atomic_long_inc(9)raw_atomic_long_inc_return(9)raw_atomic_long_inc_return_acquire(9)raw_atomic_long_inc_return_release(9)raw_atomic_long_inc_return_relaxed(9)raw_atomic_long_fetch_inc(9)raw_atomic_long_fetch_inc_acquire(9)raw_atomic_long_fetch_inc_release(9)raw_atomic_long_fetch_inc_relaxed(9)
π dec darlings
raw_atomic_long_dec(9)raw_atomic_long_dec_return(9)raw_atomic_long_dec_return_acquire(9)raw_atomic_long_dec_return_release(9)raw_atomic_long_dec_return_relaxed(9)raw_atomic_long_fetch_dec(9)raw_atomic_long_fetch_dec_acquire(9)raw_atomic_long_fetch_dec_release(9)raw_atomic_long_fetch_dec_relaxed(9)
π bit-twiddling babes (and / andnot / or / xor)
raw_atomic_long_and(9)raw_atomic_long_fetch_and(9)raw_atomic_long_fetch_and_acquire(9)raw_atomic_long_fetch_and_release(9)raw_atomic_long_fetch_and_relaxed(9)raw_atomic_long_andnot(9)raw_atomic_long_fetch_andnot(9)raw_atomic_long_fetch_andnot_acquire(9)raw_atomic_long_fetch_andnot_release(9)raw_atomic_long_fetch_andnot_relaxed(9)raw_atomic_long_or(9)raw_atomic_long_fetch_or(9)raw_atomic_long_fetch_or_acquire(9)raw_atomic_long_fetch_or_release(9)raw_atomic_long_fetch_or_relaxed(9)raw_atomic_long_xor(9)raw_atomic_long_fetch_xor(9)raw_atomic_long_fetch_xor_acquire(9)raw_atomic_long_fetch_xor_release(9)raw_atomic_long_fetch_xor_relaxed(9)
β xchg icons
raw_atomic_long_xchg(9)raw_atomic_long_xchg_acquire(9)raw_atomic_long_xchg_release(9)raw_atomic_long_xchg_relaxed(9)
π₯ cmpxchg family (our girl's cousins)
raw_atomic_long_cmpxchg(9)raw_atomic_long_cmpxchg_release(9)raw_atomic_long_cmpxchg_relaxed(9)raw_atomic_long_try_cmpxchg(9)raw_atomic_long_try_cmpxchg_acquire(9)raw_atomic_long_try_cmpxchg_release(9)raw_atomic_long_try_cmpxchg_relaxed(9)
πΈ test & negative crew
raw_atomic_long_sub_and_test(9)raw_atomic_long_dec_and_test(9)raw_atomic_long_inc_and_test(9)raw_atomic_long_add_negative(9)raw_atomic_long_add_negative_acquire(9)raw_atomic_long_add_negative_release(9)raw_atomic_long_add_negative_relaxed(9)
π§ unless / not_zero girlies
raw_atomic_long_fetch_add_unless(9)raw_atomic_long_add_unless(9)raw_atomic_long_inc_not_zero(9)raw_atomic_long_inc_unless_negative(9)raw_atomic_long_dec_unless_positive(9)raw_atomic_long_dec_if_positive(9)
β¨ cute lil sign-off β¨ this page ships from./include/linux/atomicand it's dated October 2026 β yes, the future, she's ahead of her time π . and the footer still calls herraw_atomic_...xchg_acquire(9)because the truncation is forever, iykyk. mwah π«Άπ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms