]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
workqueue: remove an unneeded UNBOUND test before waking up the next worker
authorLai Jiangshan <laijs@cn.fujitsu.com>
Tue, 22 Jul 2014 05:01:59 +0000 (13:01 +0800)
committerTejun Heo <tj@kernel.org>
Tue, 22 Jul 2014 14:37:52 +0000 (10:37 -0400)
In process_one_work():

if ((worker->flags & WORKER_UNBOUND) && need_more_worker(pool))
wake_up_worker(pool);

the first test is unneeded.  Even if the first test is removed, it
doesn't affect the wake-up logic for WORKER_UNBOUND, and it will not
introduce any useless wake-ups for normal per-cpu workers since
nr_running is always >= 1.  It will introduce useless/redundant
wake-ups for CPU_INTENSIVE, but this case is rare and the next patch
will also remove this redundant wake-up.

tj: Minor updates to the description and comment.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/workqueue.c

index d3444169e26102d42798da4686be86fa100fbf94..c20cfbe891947c740ce88a6d2a1af2e4ee22a91a 100644 (file)
@@ -2048,10 +2048,13 @@ __acquires(&pool->lock)
                worker_set_flags(worker, WORKER_CPU_INTENSIVE, true);
 
        /*
-        * Unbound pool isn't concurrency managed and work items should be
-        * executed ASAP.  Wake up another worker if necessary.
+        * Wake up another worker if necessary.  The condition is always
+        * false for normal per-cpu workers since nr_running would always
+        * be >= 1 at this point.  This is used to chain execution of the
+        * pending work items for WORKER_NOT_RUNNING workers such as the
+        * UNBOUND ones.
         */
-       if ((worker->flags & WORKER_UNBOUND) && need_more_worker(pool))
+       if (need_more_worker(pool))
                wake_up_worker(pool);
 
        /*