raw_atomic64_fetch_add(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… raw_atomic64_fetch_add β€” Kernel API Manual πŸŽ€

okay bestie, so you know how sometimes you need to add a number to a thing and also get the old number back, and you need it to be, like, atomic about it? Yeah. That's this. It's in the Kernel API Manual, and it's lowkey iconic. ✨


🌸 NAME 🌸

raw_atomic64_fetch_add β€” atomic add, but make it full ordering. Periodt. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

s64 raw_atomic64_fetch_add (s64 i , atomic64_t *v );

πŸŽ€ ARGUMENTS πŸŽ€

  • i β€” an s64. It's the value you're adding. The little guy. πŸ“
  • v β€” a pointer to atomic64_t. This is the thing getting updated, bestie.

✨ DESCRIPTION ✨

So the way this works: it atomically updates v to (v + i) β€” with full ordering. Not relaxed, not acquire, not release. Full. Ordering. The whole vibe check passed. πŸ”₯

And the tea β˜•: this one is safe to use in noinstr code. But the manpage itself says prefer atomic64_fetch_add elsewhere β€” so like, this is the special-occasion version, not the everyday one. iykyk. πŸ™ˆ


πŸ’– RETURN πŸ’–

It gives you back the original value of v. The value before the add. Fetch-and-add, babes β€” that's literally the name. You get the old one, the variable keeps the new one. We both win. 🫢


🌈 SEE ALSO 🌈

The kernel file where the magic lives: ./include/linux/atomic/atomic-arch-fallback.h

And now, the whole entire friend group πŸ’œ β€” buckle up, this is a long one:


ngl bestie, that's a LOT of friends. but like, they're all in ./include/linux/atomic and you can go read every single one. go off. πŸ‘‘

🌸 okay that's the whole page, mwah πŸ’‹ β€” this beauty comes from ./include/linux/atomic, dated October 2026, and it's the raw_atomic64_fetch_add(9) page. slay, stay atomic, and don't forget the full ordering. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from