raw_atomic_...xchg_acquire(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 an atomic_long_t. it's the thing getting compared, and maybe exchanged. main character energy tbh.
  • old β€” the long value you're comparing against. like, "is v this one? πŸ‘€"
  • new β€” the long value 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 β†’ v becomes new, acquire ordering, atomically. no match β†’ v stays 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

πŸ“ add crew

🌈 sub squad

πŸ¦‹ inc besties

πŸŽ€ dec darlings

πŸ’… bit-twiddling babes (and / andnot / or / xor)

⭐ xchg icons

πŸ”₯ cmpxchg family (our girl's cousins)

🌸 test & negative crew

🧚 unless / not_zero girlies


✨ cute lil sign-off ✨ this page ships from ./include/linux/atomic and it's dated October 2026 β€” yes, the future, she's ahead of her time πŸ’…. and the footer still calls her raw_atomic_...xchg_acquire(9) because the truncation is forever, iykyk. mwah πŸ«ΆπŸ’–
πŸ“¦ where this page comes from