wait_var_event_any_lock(9)
β¨ wait_var_event_any_lock(9) β¨
okay so this is wait_var_event_any_lock from the Kernel API Manual and bestie, it's literally the "wait for a variable to update while you're holding a lock" girlie π
buckle up.
πΈ NAME πΈ
wait_var_event_any_lock β wait for a variable to be updated under a lock π
π¦ SYNOPSIS π¦
wait_var_event_any_lock (var , condition , lock , type , state );
like that's the whole vibe, five args, no cap π«Ά
π ARGUMENTS π
varβ the address of the variable being waited on π like, the actual thing you're staring at until it changesconditionβ condition to wait for, the "am I done yet" check β³lockβ the object that is locked to protect updates to the variable π it's giving bodyguard energytypeβ prefix on lock and unlock operations β¨ yep, just a prefix, it's a whole build-your-own-function-name situationstateβ waiting state,TASK_UNINTERRUPTIBLEetc. π΄ the mood you're in while waiting
π DESCRIPTION π
So the whole concept: you wait for a condition that can only be reliably tested while holding a lock. fr fr, you can't just peek at it whenever.
The variables assessed in the condition will normal be updated under the same lock, and the wake up should be signalled with wake_up_var_locked under the same lock. π (yes it says "normal" in the original, we're not fixing it, we're respecting it π)
This is similar to wait_var_event, but assumes a lock is held while calling this function and while updating the variable. close cousins, different priorities π«
Lowkey important: this must be called while the given lock is held π€ and the lock will be dropped when schedule is called to wait for a wake up, and will be reclaimed before testing the condition again. So it's locking, unlocking, napping, waking up, re-locking, re-checking. main character multitasking energy π
The functions used to unlock and lock the object are constructed by appending _unlock and _lock to type. π οΈ so if type is foo you get foo_unlock and foo_lock β it's literally string arts and crafts, iconic.
Return -ERESTARTSYS if a signal arrives which is allowed to interrupt the wait according to state. π so if a signal shows up and state says it's allowed to interrupt you, you get -ERESTARTSYS back, periodt.
π SEE ALSO π
Kernel file ./include/linux/wait_bit.h β and the whole friend group π:
wait_on_bit(9)wait_on_bit_io(9)wait_on_bit_timeout(9)wait_on_bit_action(9)wait_on_bit_lock(9)wait_on_bit_lock_io(9)wait_on_bit_lock_action(9)wait_var_event(9)wait_var_event_io(9)wait_var_event_killable(9)wait_var_event_timeout(9)wait_var_event_interruptible(9)wait_var_event_spinlock(9)wait_var_event_mutex(9)wake_up_var_protected(9)wake_up_var_locked(9)clear_and_wake_up_bit(9)test_and_clear_wake_up_bit(9)atomic_dec_and_wake_up(9)store_release_wake_up(9)
π§ sign-off besties: this one lives in./include/linux, dated October 2026, and it's filed underwait_var_event_any_lock(9). slay, go lock something 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