wake_up_bit(9)
π« wake_up_bit(9) π«
okay so this is from the Kernel API Manual, and bestie, it's literally the page about poking the people who are napping on a bit. let's get into it π«Ά
β¨ NAME β¨
wake_up_bit β wake up waiters on a bit
πΈ SYNOPSIS πΈ
void wake_up_bit (unsigned long *word , int bit );
π ARGUMENTS π
wordβ the address containing the bit being waited onbitβ the bit at that address being waited on
π¦ DESCRIPTION π¦
So the whole vibe here is: wake up any process that's been sitting in wait_on_bit (or something similar, you know the type) waiting for the given bit to be cleared. nap time is OVER, bestie π
Now, the wake-up doesn't just get yeeted at everyone. It's sent to tasks in a waitqueue that gets selected by hash from a shared pool. And even then β only those tasks on that queue which have requested wake_up on this specific address and bit get woken. Plus only if the bit is clear. very "you have to be on the list AND the vibe has to be right" energy, ngl β¨
Here's the part where you gotta pay attention though, fr fr. For this to function properly, there must be a full memory barrier after the bit is cleared and before this function is called. no cap. If the bit was cleared atomically β like, say, by clear_bit β then smb_mb__after_atomic can be used, otherwise smb_mb is needed. If the bit was cleared with a fully-ordered operation, then no further barrier is required, you're already iconic, nothing more to do π
Also, normally the bit should be cleared by an operation with RELEASE semantics so that any changes to memory made before the bit is cleared are guaranteed to be visible after the matching wait_on_bit completes. it's giving "clean handoff" and honestly we're obsessed π
okay but seriously β skip the barrier and you get undefined-ish chaos. the memory barrier is not optional, it's the whole assignment. π
π₯ SEE ALSO π₯
Kernel file ./kernel/sched/wait_bit.c and also wake_up_var(9) β go read those next, iykyk π
and that's the page!! mwah π β this lil gem comes to you from ./kernel/sched, dated October 2026, and it's wake_up_bit(9) all day every day. go wake up some waiters responsibly, 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