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.
Showing the changes to kernel/workqueue.c (1 of 1 file). Show all
Unified · Split
| @@ -5461,16 +5461,17 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq) · 5460 unmodified lines | ||
| 5461 | 5461 | goto enomem; |
| 5462 | 5462 | |
| 5463 | 5463 | if (!(wq->flags & WQ_UNBOUND)) { |
| 5464 | + struct worker_pool __percpu *pools; | |
| 5465 | + | |
| 5466 | + if (wq->flags & WQ_BH) | |
| 5467 | + pools = bh_worker_pools; | |
| 5468 | + else | |
| 5469 | + pools = cpu_worker_pools; | |
| 5470 | + | |
| 5464 | 5471 | for_each_possible_cpu(cpu) { |
| 5465 | 5472 | struct pool_workqueue **pwq_p; |
| 5466 | − struct worker_pool __percpu *pools; | |
| 5467 | 5473 | struct worker_pool *pool; |
| 5468 | 5474 | |
| 5469 | − if (wq->flags & WQ_BH) | |
| 5470 | − pools = bh_worker_pools; | |
| 5471 | − else | |
| 5472 | − pools = cpu_worker_pools; | |
| 5473 | − | |
| 5474 | 5475 | pool = &(per_cpu_ptr(pools, cpu)[highpri]); |
| 5475 | 5476 | pwq_p = per_cpu_ptr(wq->cpu_pwq, cpu); |
| 5476 | 5477 | |