]> www.infradead.org Git - users/hch/xfs.git/commitdiff
workqueue: Clean code in alloc_and_link_pwqs()
authorWenchao Hao <haowenchao22@gmail.com>
Thu, 6 Jun 2024 08:52:16 +0000 (16:52 +0800)
committerTejun Heo <tj@kernel.org>
Fri, 7 Jun 2024 16:27:04 +0000 (06:27 -1000)
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>
kernel/workqueue.c

index 003474c9a77d09d3d025b4ceed42c64179551323..f70ac724ca7b323ea1b95a1bfaae1dc7790b709a 100644 (file)
@@ -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);