complete_all(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

okay so this page is complete_all β€” it's from the Kernel API Manual, section 9, and bestie it signals all threads waiting on this completion. that's the whole vibe. all of them. not one, not two, ALL. πŸ‘‘


✨ SYNOPSIS ✨

void complete_all (struct completion *x );

literally that's it. one function, one pointer, infinite group-chat notifications. πŸ’…


πŸŽ€ ARGUMENTS πŸŽ€

  • x β€” holds the state of this particular completion. it's the main character here, it's carrying all the state for this specific completion and honestly? iconic. 🫢

🌸 DESCRIPTION 🌸

so here's the tea: this will wake up all threads waiting on this particular completion event. every single one of them. the whole waiting list gets the notification at once, no cap. πŸ”₯

and if this function wakes up a task, it executes a full memory barrier before accessing the task state. like, memory ordering is handled, don't stress. ✨

now the important part, and i mean very important, so listen up bestie πŸ’€:

since complete_all sets the completion of x permanently to done to allow multiple waiters to finish, a call to reinit_completion must be used on x if x is to be used again. periodt. no exceptions.

and your code must make sure that all waiters have woken and finished before reinitializing x. like, wake everybody up, let them actually finish their little tasks, then reinit. in that order. the way that out-of-order reinit will ruin your whole life 😭

also note β€” and this one gets everybody β€” the function completion_done can not be used to know if there are still waiters after complete_all has been called. it just can't. don't try it. it's giving "asking a brick wall how everyone's doing." πŸ™ˆ

tl;dr: complete_all opens the floodgates forever, so reinit_completion is your reset button, and completion_done is not your waiter detector. 🧚


πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file ./kernel/sched/completion.c plus the whole completion friend group, all tagged section 9:

go read them, they're all slay in their own way πŸŽ€


and that's the page!! stay hydrated, reinit responsibly, and remember this one's coming at you from ./kernel/sched, dated October 2026 β€” complete_all(9), that's a wrap bestie πŸ’œπŸŒˆβ­

πŸ“¦ where this page comes from