hwspin_lock_timeout_irqsave(9)
π hwspin_lock_timeout_irqsave(9) β from the Kernel API Manual, bestie π
okay so this is a page from the Kernel API Manual, and it's literally about hwspin_lock_timeout_irqsave β the hwspinlock grab that also turns off your interrupts. it's giving "responsible main character" energy, ngl π
β¨ NAME β¨
hwspin_lock_timeout_irqsave β lock that hwspinlock, but with a timeout, and disable your irqs while you're at it π«Ά
β¨ SYNOPSIS β¨
int hwspin_lock_timeout_irqsave (struct hwspinlock *hwlock , unsigned int to , unsigned long *flags );
π¦ ARGUMENTS π¦
hwlockβ the hwspinlock you're trying to lock, bestie. the whole point of the function πtoβ the timeout value, measured in msecs. that's how long you're willing to wait before you're like "okay nvm" πflagsβ a pointer to where your caller's interrupt state is gonna get saved. it's a save slot, basically π
πΈ DESCRIPTION πΈ
so here's the tea. this function locks the underlying hwlock. iconic behaviour, no notes π₯
if the hwlock is already taken, it doesn't just give up β it busy loops waiting for it to be released. like, actively spinning. the dedication fr fr. but it's not gonna spin forever, because it gives up when timeout msecs have elapsed. boundaries! we love to see it π
upon a successful return from this function, preemption and local interrupts are disabled (plus the previous interrupt state is saved). so heads up, because this is the important part:
π¨ the caller must not sleep, and is advised to release the hwspinlock as soon as possible. like, immediately. do not be out here holding it while you go do side quests π
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 timeout msecs. and the function will never sleep. not even a lil nap. periodt π
π SEE ALSO π
kernel file ./include/linux/hwspinlock.h, plus the whole friend group:
hwspin_trylock_irqsave(9)hwspin_trylock_irq(9)hwspin_trylock_raw(9)hwspin_trylock_in_atomic(9)hwspin_trylock(9)hwspin_lock_timeout_irq(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)
π§ and that's the whole page, bestie! this lil slice of the manual lives in ./include/linux, dated October 2026, filed under hwspin_lock_timeout_irqsave(9). go forth and lock responsibly πβ¨π
π¦ 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