raw_atomic_sub_and_test(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸŽ€ NAME πŸŽ€

okay so bestie, this page is raw_atomic_sub_and_test(9) from the Kernel API Manual β€” she’s the atomic subtract-and-test-if-zero icon with full ordering, and she is literally here to tell you if v hits zero after the math. no cap. πŸ’…

✨ SYNOPSIS ✨

bool raw_atomic_sub_and_test (int i , atomic_t *v );

🫢 ARGUMENTS 🫢

  • i β€” the int value you’re subtracting. it’s giving β€œhow much are we taking off?” πŸ’–
  • v β€” pointer to atomic_t. this is the atomic variable getting updated, main character energy only. ✨

πŸ’– DESCRIPTION πŸ’–

Atomically updates v to (v - i) with full ordering. so the subtract and the update happen as one atomic little moment, and the ordering is full β€” yes, that’s the whole vibe.

Safe to use in noinstr code; prefer atomic_sub_and_test elsewhere. like, if you’re in noinstr land she’s safe to use, but the rest of the time the preferred bestie is atomic_sub_and_test. 🫢

🌸 RETURN 🌸

  • true if the resulting value of v is zero. πŸŽ‰
  • false otherwise. πŸ’€

literally that’s the whole answer, no extra plot twist.

πŸ¦‹ SEE ALSO πŸ¦‹

  • Kernel file: ./include/linux/atomic/atomic-arch-fallback.h

🫢 the raw_atomic_* fam

🫢 the raw_atomic64_* fam


xoxo, your kernel bestie πŸ’– β€” signed off with source ./include/linux/atomic, version/date October 2026, and the page is raw_atomic_sub_and_test(9). periodt. πŸ¦‹

πŸ“¦ where this page comes from