devm_alloc_workqueue(9)
π devm_alloc_workqueue(9) β from the Kernel API Manual, bestie
okay so picture this: you're a driver dev, you need a workqueue, and you do not want to write destroy-on-detach cleanup code like some kind of Victorian orphan. enter devm_alloc_workqueue. it's the resource-managed glow-up of workqueue allocation, and honestly? iconic. β¨
β¨ NAME β¨
devm_alloc_workqueue β resource-managed allocate a workqueue π
πΈ SYNOPSIS πΈ
struct workqueue_struct * devm_alloc_workqueue (struct device *dev ,
const char *fmt , unsigned int flags , int max_active , ... );
like, that's the whole vibe. look at it. five things, and then ... just hanging out at the end doing its little variadic thing π«Ά
π ARGUMENTS π
devβ the device you're allocating this workqueue for. it's the whole reason the managed magic works, so pls don't get cute with it.fmtβ aprintfformat string for the name of the workqueue. that's the name, bestie, so make it a good one.flagsβ theWQ_*flags. capitals, underscore, go read the docs on those because this page isn't gonna spell them out for you.max_activeβ max in-flight work items. pass0and you get the default, ez pz....β the args forfmt. your classic variadic situation. no notes.
π¦ DESCRIPTION π¦
so it's a resource managed workqueue β and if you want the full deep-dive deets, go see alloc_workqueue. that's the real one. this one's the managed version of it.
the headline here, the main character energy of this page: the workqueue will be automatically destroyed on driver detach. β¨ no manual teardown era. we simply do not clean up by hand anymore.
typically you should use this in drivers that are already relying on devm interfaces β like, don't be the one driver in the tree doing something different, iykyk. keep it consistent, it's giving very "everybody else is doing it, so should u" but in the healthy way π
π₯ RETURN π₯
- success β a
Pointerto the allocated workqueue π - failure β
NULLπ (yes, check it. always check it. no cap.)
π§ SEE ALSO π§
the full squad, no one left behind:
- Kernel file
./include/linux/workqueue.hstructworkqueue_attrs(9) work_pending(9)delayed_work_pending(9)alloc_workqueue(9)alloc_workqueue_lockdep_map(9)alloc_ordered_workqueue_lockdep_map(9)alloc_ordered_workqueue(9)queue_work(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)
and that's the page!! π sign-off time, mwah π β this lil beauty lives in ./include/linux, dated October 2026, and it goes by devm_alloc_workqueue(9). go forth and manage your resources 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