wait_var_event_any_lock(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ 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 changes
  • condition β€” 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 energy
  • type β€” prefix on lock and unlock operations ✨ yep, just a prefix, it's a whole build-your-own-function-name situation
  • state β€” waiting state, TASK_UNINTERRUPTIBLE etc. 😴 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 πŸ’œ:


🧚 sign-off besties: this one lives in ./include/linux, dated October 2026, and it's filed under wait_var_event_any_lock(9). slay, go lock something responsibly πŸ’…βœ¨πŸŽ€
πŸ“¦ where this page comes from