atomic64_add_return(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ‘‘ atomic64_add_return πŸ‘‘

okay so real talk, bestie β€” this is the atomic64_add_return page from the Kernel API Manual, and it's honestly kind of iconic for how much it does with so little. Like, the whole thing is four sentences and then a SEE ALSO section that goes on forever (me at a party fr fr πŸ’€).


πŸ’– NAME πŸ’–

atomic64_add_return β€” atomic add with full ordering. that's it, that's the vibe ✨

πŸŽ€ SYNOPSIS πŸŽ€

s64 atomic64_add_return (s64 i , atomic64_t *v );

like, copy it exactly, don't @ me about the spacing 🫢

πŸ¦‹ ARGUMENTS πŸ¦‹

  • i β€” the s64 value you're adding. the amount. the little extra you're sliding in πŸ’…
  • v β€” pointer to an atomic64_t. this is your target, your main character, the one getting updated 🌸

πŸ”₯ DESCRIPTION πŸ”₯

so what it actually does: it atomically updates v to (v + i) with full ordering. atomically means nobody's gonna catch it mid-update, no weird partial states, no race-condition drama, we do not do that here πŸ”’βœ¨ full ordering means the memory ordering is the whole package, not the relaxed little cousin version.

⚠️ okay but listen β€” this is unsafe to use in noinstr code. not "kind of sketchy," actually unsafe. if you're in noinstr territory, use raw_atomic64_add_return there instead. periodt πŸ’€

⭐ RETURN ⭐

it hands you back the updated value of v. so like, the value after the add, not before. that's the difference between this and the fetch-flavoured ones, iykyk 🌈

🌈 SEE ALSO 🌈

so. this is the part where it goes off. the kernel file is ./include/linux/atomic/atomic-instrumented.h and the whole family reunion is listed below β€” every single one of them, no cap πŸ‘‘

the atomic_ girlies πŸ’…

the atomic64_ squad πŸ¦‹ (our girl's home team)

and the atomic_long_ cousins 🌸


okay and before I go β€” the source for all this is ./include/linux/atomic, dated October 2026, and the page itself is atomic64_add_return(9). mwah, go add some numbers atomically bestie πŸ§šβ€β™€οΈπŸ’œ

πŸ“¦ where this page comes from