hwspin_lock_timeout_irqsave(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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:


🧚 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