Skip to content

Commit

Permalink
workqueue: Clean code in alloc_and_link_pwqs()
Browse files Browse the repository at this point in the history
wq->flags would not change, so it's not necessary to check if WQ_BH
is set in loop for_each_possible_cpu(), move define and set of pools
out of loop to simpliy the code.

Signed-off-by: Wenchao Hao <haowenchao22@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Wenchao Hao authored and Tejun Heo committed Jun 7, 2024
1 parent 8a92980 commit 7ccc215
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -5461,16 +5461,17 @@ 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 __percpu *pools;
struct worker_pool *pool;

if (wq->flags & WQ_BH)
pools = bh_worker_pools;
else
pools = cpu_worker_pools;

pool = &(per_cpu_ptr(pools, cpu)[highpri]);
pwq_p = per_cpu_ptr(wq->cpu_pwq, cpu);

Expand Down

0 comments on commit 7ccc215

Please sign in to comment.