[PATCH 0/3] workqueue: sparse and wq_node_nr_active() fixes

Breno Leitao posted 3 patches 1 month, 2 weeks ago
kernel/workqueue.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
[PATCH 0/3] workqueue: sparse and wq_node_nr_active() fixes
Posted by Breno Leitao 1 month, 2 weeks ago
This is a follow up for the patchset named "workqueue: base pwq pool
release and nr_active on the backing pool"

Patches 1 and 2 answer a 0-day sparse report against the percpu pwq
allocation path, bisected to commit 79f23600bc7b ("workqueue: factor out
get_percpu_pool()").

https://lore.kernel.org/all/202608120931.tvTzq1gD-lkp@intel.com/

The warning is not new, that commit only turned the offending assignment
into an initializer. wq->cpu_pwq is an array of __rcu pointers, but
workqueue_congested(), the allocation path and its error path all go
through it with plain loads and stores. Use the matching RCU accessors
instead.

With the two patches kernel/workqueue.c is sparse clean.

Patch 3 is a separate review fix: wq_node_nr_active() warns and returns
NULL for a per-cpu workqueue, which only moves the oops into the caller.

This has been stress tested with a "debug" kernel and wqtest test-suite:
https://github.com/leitao/wqtest

Signed-off-by: Breno Leitao <leitao@debian.org>
---
Breno Leitao (3):
      workqueue: use rcu_dereference_sched() in workqueue_congested()
      workqueue: use RCU accessors when populating wq->cpu_pwq
      workqueue: BUG_ON() instead of returning NULL in wq_node_nr_active()

 kernel/workqueue.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
---
base-commit: 5e6de6a2b522f659defacb1551d0465ba6ce13cf
change-id: 20260812-wq_fix-be919bd89542

Best regards,
--  
Breno Leitao <leitao@debian.org>
Re: [PATCH 0/3] workqueue: sparse and wq_node_nr_active() fixes
Posted by Tejun Heo 1 month, 2 weeks ago
On Wed, Aug 12, 2026 at 09:03:17AM -0700, Breno Leitao wrote:
> Breno Leitao (3):
>       workqueue: use rcu_dereference_sched() in workqueue_congested()
>       workqueue: use RCU accessors when populating wq->cpu_pwq
>       workqueue: BUG_ON() instead of returning NULL in wq_node_nr_active()

Applied 1-3 to wq/for-7.3.

Thanks.

-- 
tejun