spin_is_locked(9)
π 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 β
1iflockis locked π0otherwise πΈ
π SEE ALSO π
Kernel file ./include/linux/spinlock.h
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms