diff options
| author | Breno Leitao <leitao@debian.org> | 2026-08-05 07:52:28 -0700 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2026-08-10 11:47:03 -1000 |
| commit | 79f23600bc7b13a35fd148131245c283d14604a8 (patch) | |
| tree | 911d4c1a8bc2a35c7bcfb12f5c8fd9c82a7810fd /kernel | |
| parent | dbff1ec23f68640a743512e8ada125795d1b72c7 (diff) | |
workqueue: factor out get_percpu_pool()
Move the static per-cpu worker_pool lookup in alloc_and_link_pwqs() into
a helper, get_percpu_pool(), so the lookup can be shared by other
pool-selection paths.
No functional change.
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/workqueue.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 4ec3db31493d..63a39bb3f5e4 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5350,6 +5350,20 @@ static void link_pwq(struct pool_workqueue *pwq) list_add_tail_rcu(&pwq->pwqs_node, &wq->pwqs); } +/* Return the static per-cpu worker_pool that backs @wq on @cpu. */ +static struct worker_pool *get_percpu_pool(struct workqueue_struct *wq, int cpu) +{ + struct worker_pool __percpu *pools; + bool highpri = wq->flags & WQ_HIGHPRI; + + if (wq->flags & WQ_BH) + pools = bh_worker_pools; + else + pools = cpu_worker_pools; + + return &per_cpu_ptr(pools, cpu)[highpri]; +} + /* obtain a pool matching @attr and create a pwq associating the pool and @wq */ static struct pool_workqueue *alloc_unbound_pwq(struct workqueue_struct *wq, const struct workqueue_attrs *attrs) @@ -5664,19 +5678,9 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq) goto enomem; if (!(wq->flags & WQ_UNBOUND)) { - struct worker_pool __percpu *pools; - - if (wq->flags & WQ_BH) - pools = bh_worker_pools; - else - pools = cpu_worker_pools; - for_each_possible_cpu(cpu) { - struct pool_workqueue **pwq_p; - struct worker_pool *pool; - - pool = &(per_cpu_ptr(pools, cpu)[highpri]); - pwq_p = per_cpu_ptr(wq->cpu_pwq, cpu); + struct pool_workqueue **pwq_p = per_cpu_ptr(wq->cpu_pwq, cpu); + struct worker_pool *pool = get_percpu_pool(wq, cpu); *pwq_p = kmem_cache_alloc_node(pwq_cache, GFP_KERNEL, pool->node); |
