queue_work(9)
π queue_work(9) β the Kernel API Manual, but make it make sense π
okay so bestie, this one lives in the Kernel API Manual section 9 and honestly? it's a whole vibe. it's like the post it note of the workqueue world: "hey, pls run this later." let's get into it β¨
β¨ NAME β¨
queue_work β queue work on a workqueue π«Ά
like, that's it. that's the whole job. you hand it a thing and it goes "say less, it's queued."
πΈ SYNOPSIS πΈ
bool queue_work (struct workqueue_struct *wq , struct work_struct *work
);
so you get a bool back, bestie. a whole true-or-false. feral behaviour but ok π₯
π¦ ARGUMENTS π¦
wqβ the workqueue to use. this is the venue, the venue is booked, we're going πworkβ the work to queue. this is the main character of the operation, the thing that's actually gonna run π
π DESCRIPTION π
so, the return value? it's giving boolean drama. it returns false if the work was already on a queue, and true otherwise. so like, false = "girl it's already in line", true = "congrats, fresh queue entry, slay" β¨
we queue the work to the CPU on which it was submitted β very much "you grew here, you're one of us" energy π₯Ί β but if that CPU dies, it can be processed by another CPU. no cap, the work survives, the CPU does not ππ
Memory-ordering properties: ooh okay this is the important part, pay attention bestie π β if it returns true, that guarantees all stores preceding the call to queue_work in program order will be visible from the CPU which will execute work by the time such work executes, e.g.
{ x is initially 0 }
CPU0 CPU1
WRITE_ONCE(x, 1); [ work is being executed ] r0 =
queue_work(wq, work); r1 = READ_ONCE(x);
Forbids: r0 == true && r1 == 0
like literally forbidden. not allowed. don't even think about it π«π
ngl the memory ordering bit is the loading-screen lore you cannot skip. it's a guarantee, not a suggestion. if you're doing theWRITE_ONCEβqueue_workcombo and the other side reads withREAD_ONCE, ther0 == true && r1 == 0scenario is off the table. periodt. π
π SEE ALSO π
the whole friend group, honestly β go read these too, iykyk π«Ά
- Kernel file
./include/linux/workqueue.hstruct workqueue_attrs(9) work_pending(9)delayed_work_pending(9)alloc_workqueue(9)devm_alloc_workqueue(9)alloc_workqueue_lockdep_map(9)alloc_ordered_workqueue_lockdep_map(9)alloc_ordered_workqueue(9)queue_delayed_work(9)mod_delayed_work(9)schedule_work_on(9)schedule_work(9)enable_and_queue_work(9)schedule_delayed_work_on(9)schedule_delayed_work(9)
π one (1) tiny thing before you go: it returnstrueonly when it actually queued something new β afalseis not an error, it's just "been there, queued that." don't @ me, it's literally what the manpage says π«Ά
k that's the whole page, ily, go queue some work π β¨
β from ./include/linux, dated October 2026, queue_work(9) out ππ¦π
π¦ 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