wait_event_...lock_irq_cmd(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’€ wait_event_interruptible_lock_irq_cmd(9) β€” the "sleep till it's true, but hold the lock and run a lil command" macro πŸ’€

okay so bestie, welcome to the Kernel API Manual, section 9 β€” this is the page for wait_event_interruptible_lock_irq_cmd, and yes the header up top is all wait_event_...lock_irq_cmd(9) because that name is long and the manpage machinery got shy. same macro tho. πŸŽ€


✨ NAME ✨

wait_event_interruptible_lock_irq_cmd β€” sleep until a condition gets true. the condition is checked under the lock. this is expected to be called with the lock taken. πŸ’…


✨ SYNOPSIS ✨

wait_event_interruptible_lock_irq_cmd (wq_head , condition , lock , cmd );

like, four things go in. that's it. that's the whole vibe. πŸ¦‹


✨ ARGUMENTS ✨

  • wq_head β€” the waitqueue to wait on. this is the lil hangout spot where your process chills until someone wakes it up. 🌸
  • condition β€” a C expression for the event to wait for. it's literally just "am I done yet" written as code. πŸ”₯
  • lock β€” a locked spinlock_t, which will be released before cmd and schedule and reacquired afterwards. yes, it lets go of the lock mid-macro. that's the whole point, don't panic. πŸ’œ
  • cmd β€” a command which is invoked outside the critical section before sleep. it runs before you snooze, and it runs unlocked. 🧚

✨ DESCRIPTION ✨

so the process gets put to sleep (TASK_INTERRUPTIBLE) until the condition evaluates to true or a signal is received. the condition is checked each time the waitqueue wq_head is woken up. πŸ‘‘

wake_up has to be called after changing any variable that could change the result of the wait condition. no cap β€” if you flip the variable and forget the wake_up, your poor process is gonna be napping forever and that's on you, bestie. 😭

this is supposed to be called while holding the lock. the lock is dropped before invoking the cmd and going to sleep and is reacquired afterwards. so the sequence is giving: hold lock β†’ drop it β†’ run cmd β†’ sleep β†’ wake up β†’ reacquire lock. iconic, honestly. ✨

the macro will return -ERESTARTSYS if it was interrupted by a signal and 0 if condition evaluated to true. those are the only two moods. πŸ’€

✨ SEE ALSO ✨

Kernel file ./include/linux/wait.h β€” and the whole waitqueue friend group, fr fr:


okay that's the whole page, you ate that 🫢 this one lives in ./include/linux, dated October 2026, and the title up in the corner is wait_event_...lock_irq_cmd(9) β€” go forth and wait on your waitqueues responsibly, mwah πŸ’–πŸŒ·

πŸ“¦ where this page comes from