queue_work(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 the WRITE_ONCE β†’ queue_work combo and the other side reads with READ_ONCE, the r0 == true && r1 == 0 scenario is off the table. periodt. πŸŽ€

🌈 SEE ALSO 🌈

the whole friend group, honestly β€” go read these too, iykyk 🫢


πŸ’– one (1) tiny thing before you go: it returns true only when it actually queued something new β€” a false is 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