spin_is_locked(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… spin_is_locked(9) β€” the Kernel API Manual, bestie edition πŸŽ€

Okay so we're in the spin_is_locked(9) manpage today, and yes she's from the Kernel API Manual, and yes she's iconic, let's get into it ✨


🌸 NAME 🌸

spin_is_locked β€” check whether a spinlock is locked, that's literally it, that's the whole vibe πŸ’–


✨ SYNOPSIS ✨

int spin_is_locked (spinlock_t *lock );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • lock β€” a pointer to the spinlock, bestie. That's the one you're asking about 🫢

πŸ‘‘ DESCRIPTION πŸ‘‘

Okay so the first thing you need to know, and I mean really know: this function is NOT required to provide any memory ordering guarantees. Like, none. Zero. Not a single one. Ngl she's just out here existing 😭

So what's she even for? She could be used for debugging purposes β€” very that β€” or, when you actually need additional synchronization, she gets accompanied with other constructs (memory barriers, the real ones) that enforce the synchronization. She's the supporting character, not the main character energy πŸ’…

Note that the function only tells you that the spinlock is seen to be locked β€” not that it is locked on your CPU. Huge distinction. Massive. Do not conflate them πŸ™ˆ

Further, on CONFIG_SMP=n builds with CONFIG_DEBUG_SPINLOCK=n, the return value is always 0 (see include/linux/spinlock_up.h). So basically in that config she's out here giving nothing 🧚 Therefore you should not rely heavily on the return value. Like, don't build your whole personality on it, fr fr πŸ’€


⭐ RETURN ⭐

  • 1 if lock is locked πŸ’–
  • 0 otherwise 🌸

🌈 SEE ALSO 🌈

Kernel file ./include/linux/spinlock.h

atomic_dec_and_lock(9)


And that's the page, bestie β€” sending you off with the source ./include/linux and the date October 2026, mwah, slay, periodt πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from