alloc_workqueue(9)
β¨ alloc_workqueue β allocate a workqueue β¨
okay so this is a page straight out of the Kernel API Manual, bestie, and it's literally about making a brand-new workqueue. iconic behavior. let's get into it π
π SYNOPSIS π
struct workqueue_struct * alloc_workqueue (const char *fmt , unsigned
int flags , int max_active , ... );
πΈ ARGUMENTS πΈ
fmtβ aprintfformat for the name of the workqueue. yes, the name is a format string, so it can be fancy πflagsβ theWQ_*flags. all the vibes live here.max_activeβ the max in-flight work items. pass0and you get the default, no stress π«Ά...β the args forfmt. the format string's little entourage β¨
π DESCRIPTION π
okay so first thing: this depends on what kind of workqueue you're making, and max_active behaves differently for each. pay attention bestie, this is the main character part π
For a per-cpu workqueue, max_active limits the number of in-flight work items for each CPU. like, max_active of 1 means each CPU can be executing at most one work item for the workqueue. one. per CPU. that's it. β
For unbound workqueues, max_active limits the number of in-flight work items for the whole system. so max_active of 16 means there can be at most 16 work items executing for the workqueue across the entire whole system. global girlies π
now here's the spicy bit πΆοΈ β sharing the same active counter for an unbound workqueue across multiple NUMA nodes can be expensive, so instead max_active gets distributed to each NUMA node according to the proportion of the number of online CPUs, and then enforced independently. math girl summer π
β οΈ and because of online CPU distribution, a node may end up with a per-nodemax_activethat's significantly lower thanmax_active. that can lead to deadlocks if the per-node concurrency limit drops below the maximum number of interdependent work items for the workqueue. not cute. not slay. actual deadlock energy. π
to guarantee forward progress regardless of online CPU distribution, the concurrency limit on every node is guaranteed to be equal to or greater than min_active, which is set to min(max_active, WQ_DFL_MIN_ACTIVE). π§
and the consequence? the sum of the per-node max_active's may be larger than max_active. yeah. the numbers don't have to add up and that's on purpose, periodt π
for the detailed info on WQ_flags, please refer to Documentation/core-api/workqueue.rst. go read it, iykyk π
π¦ RETURN π¦
pointer to the allocated workqueue on success, NULL on failure. simple. clean. either you ate or you didn't π
π SEE ALSO π
kernel file ./include/linux/workqueue.h and the whole squad:
struct workqueue_attrs(9)work_pending(9)delayed_work_pending(9)devm_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)
okay that's the whole page bestie, you're officially a workqueue girlie now π this one came from the Kernel API Manual, sourced out of ./include/linux, dated October 2026, and it's filed under alloc_workqueue(9). mwah πβ¨
π¦ 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