wait_var_event_io(9)
π€ wait_var_event_io(9) β the Kernel API Manual, bestie edition π€
okay so this is wait_var_event_io, straight out of the Kernel API Manual, and it's lowkey iconic for anyone doing IO-ish waiting in kernel land. let me put you on π«Ά
β¨ NAME β¨
wait_var_event_io β wait for a variable to be updated and notified. that's it, that's the whole vibe π
πΈ SYNOPSIS πΈ
wait_var_event_io (var , condition );
literally just hand it a var and a condition and let it cook π
π ARGUMENTS π
varβ the address of the variable you're waiting on. yes, an address. not the value, the address. main character energy πconditionβ the condition to wait for. that's the thing you're sitting around refreshing like a group chat until it's true π
π¦ DESCRIPTION π¦
so here's the tea: you're waiting for an IO related condition to be true, and the way this works is it only re-checks when a wake up is received for the given var. and var is an arbitrary kernel address β which, fun fact, need not be directly related to the given condition, but usually is. iykyk π§
the process will wait on a waitqueue selected by hash from a shared pool. so yes, hashed. shared. pool. it's giving efficient π
and it will only be woken on a wake_up for the given address. no address, no wakey. periodt.
this is similar to wait_var_event, but β and this is the whole reason this function exists β it calls io_schedule instead of schedule. that's the difference. that's the moment. π₯
β οΈ okay important bestie moment: the condition should normally use smp_load_acquire or a similarly ordered access. why? to ensure that any changes to memory made before the condition became true will be visible after the wait completes. this is not optional vibes, this is memory ordering, please respect it π
π SEE ALSO π
the kernel file is ./include/linux/wait_bit.h β go read it fr fr, and here's 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_killable(9)wait_var_event_timeout(9)wait_var_event_interruptible(9)wait_var_event_any_lock(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)
and that's the page!! π it lives over in ./include/linux, dated October 2026 β so yeah, bookmark it, screenshot it, send it to the group chat π you're welcome, bestie π«Άβ¨
π¦ 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