atomic_fetch_add_relaxed(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… atomic_fetch_add_relaxed(9) β€” the relaxed little adder that slays

okay so bestie, quick vibe check: this is a page from the Kernel API Manual, and today's main character is atomic_fetch_add_relaxed. she's a tiny function, she's got one job, and she does it flawlessly. no cap. 🫢


✨ NAME ✨

atomic_fetch_add_relaxed β€” atomic add, but make the ordering relaxed πŸ’†β€β™€οΈ


πŸŽ€ SYNOPSIS πŸŽ€

int atomic_fetch_add_relaxed (int i , atomic_t *v );

that's it. that's the whole signature. look at her go πŸ‘‘


πŸ¦‹ ARGUMENTS πŸ¦‹

  • i β€” an int, literally just the value you wanna add. that's the whole personality. πŸ’–
  • v β€” pointer to an atomic_t. this is the queen being updated, show some respect. πŸ‘‘

🌸 DESCRIPTION 🌸

so what she does: she atomically updates v to (v + i), with relaxed ordering. atomically means nobody can catch her mid-update and see a cursed half-finished value β€” it's giving main character energy, all or nothing. ✨

as for "relaxed"? she's chill. she's not doing the whole song-and-dance of ordering guarantees the _acquire and _release girlies do. lowkey just vibes. ngl that's the whole point of picking her. πŸ’…

🚨 okay important safety moment: unsafe to use in noinstr code. fr fr. if you're in noinstr land, use raw_atomic_fetch_add_relaxed there instead. do not test her on this, she will not pass the vibe check. 😭

⭐ RETURN ⭐

she gives you back the original value of v β€” the value before the add happened. iconic behavior honestly, she adds first and tells you what it used to be after, like a true bestie who remembers the old you. πŸ₯ΉπŸ’œ


🌈 SEE ALSO 🌈

okay bestie buckle up, because this list is long. the kernel file for this is ./include/linux/atomic/atomic-instrumented.h and here's literally the whole family β€” every single one of these is living in the same house and you should know their names: 🏑

πŸ“ the atomic_* girlies

πŸŽ€ the atomic64_* icons

πŸ’œ the atomic_long_* legends


and that's the whole page, bestie!! 🫢✨ go forth and add things atomically, remember the noinstr rule, and drink some water. πŸ’–

🌸 cute little sign-off: this came out of the kernel source at ./include/linux/atomic, dated October 2026, and it's literally titled atomic_fetch_add_relaxed(9). mwah. πŸ’‹
πŸ“¦ where this page comes from