hwspin_lock_timeout_irq(9)
π hwspin_lock_timeout_irq(9) β from the Kernel API Manual, bestie
okay so real talk, this is a page straight out of the Kernel API Manual and it's about grabbing a hardware spinlock without letting your whole world hang forever. she waits, but she has boundaries. periodt.
β¨ NAME β¨
hwspin_lock_timeout_irq β lock a hwspinlock, but with a timeout, and disable irqs while you're at it π
β¨ SYNOPSIS β¨
int hwspin_lock_timeout_irq (struct hwspinlock *hwlock , unsigned int to );
β¨ ARGUMENTS β¨
hwlockβ the hwspinlock you're trying to lock, like the door you wanna get through πͺtoβ the timeout value, and it's in msecs (milliseconds, not vibes) β±οΈ
πΈ DESCRIPTION πΈ
So this function locks the underlying hwlock. simple enough, right?
But here's the tea: if the hwlock is already taken, she doesn't just give up immediately β she busy loops, waiting for it to be released π. The catch is she has a limit, and once to msecs have elapsed she's like "okay bestie I'm out" and gives up. no cap.
Upon a successful return from this function, preemption and local interrupts are disabled, so lowkey the caller must NOT sleep π΄π« β and you're advised to release the hwspinlock as soon as possible. like, don't sit on it. it's not a chair. πͺπ
It returns 0 when the hwlock was successfully taken, and an appropriate error code otherwise β most notably an -ETIMEDOUT if the hwlock is still busy after to msecs π. And one more time for the people in the back: the function will never sleep. ever. not once. π«Ά
π¦ SEE ALSO π¦
The source lives in the kernel file ./include/linux/hwspinlock.h, and honestly the whole friend group is iconic:
hwspin_trylock_irqsave(9)hwspin_trylock_irq(9)hwspin_trylock_raw(9)hwspin_trylock_in_atomic(9)hwspin_trylock(9)hwspin_lock_timeout_irqsave(9)hwspin_lock_timeout_raw(9)hwspin_lock_timeout_in_atomic(9)hwspin_lock_timeout(9)hwspin_unlock_irqrestore(9)hwspin_unlock_irq(9)hwspin_unlock_raw(9)hwspin_unlock_in_atomic(9)hwspin_unlock(9)
β οΈ friendly reminder: successful return means preemption and local interrupts are off and you must not sleep. treat this lock like a hot potato, not a long-term relationship π π₯
okay that's the whole page, mwah π β this one ships from ./include/linux, dated October 2026. go lock responsibly, bestie ππ
π¦ 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