[PATCH 2/2] workqueue: cleancode in alloc_and_link_pwqs()

From: Wenchao Hao
Date: Thu Jun 06 2024 - 04:55:12 EST


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@xxxxxxxxx>
---
kernel/workqueue.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 3fbaecfc88c2..078d56ddbe3a 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -5477,16 +5477,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);

--
2.38.1