Skip to content

Commit 01341fb

Browse files
yeyunfeng-devhtejun
authored andcommitted
workqueue: Kick a worker based on the actual activation of delayed works
In realtime scenario, We do not want to have interference on the isolated cpu cores. but when invoking alloc_workqueue() for percpu wq on the housekeeping cpu, it kick a kworker on the isolated cpu. alloc_workqueue pwq_adjust_max_active wake_up_worker The comment in pwq_adjust_max_active() said: "Need to kick a worker after thawed or an unbound wq's max_active is bumped" So it is unnecessary to kick a kworker for percpu's wq when invoking alloc_workqueue(). this patch only kick a worker based on the actual activation of delayed works. Signed-off-by: Yunfeng Ye <[email protected]> Reviewed-by: Lai Jiangshan <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 127c501 commit 01341fb

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

kernel/workqueue.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,17 +3728,24 @@ static void pwq_adjust_max_active(struct pool_workqueue *pwq)
37283728
* is updated and visible.
37293729
*/
37303730
if (!freezable || !workqueue_freezing) {
3731+
bool kick = false;
3732+
37313733
pwq->max_active = wq->saved_max_active;
37323734

37333735
while (!list_empty(&pwq->delayed_works) &&
3734-
pwq->nr_active < pwq->max_active)
3736+
pwq->nr_active < pwq->max_active) {
37353737
pwq_activate_first_delayed(pwq);
3738+
kick = true;
3739+
}
37363740

37373741
/*
37383742
* Need to kick a worker after thawed or an unbound wq's
3739-
* max_active is bumped. It's a slow path. Do it always.
3743+
* max_active is bumped. In realtime scenarios, always kicking a
3744+
* worker will cause interference on the isolated cpu cores, so
3745+
* let's kick iff work items were activated.
37403746
*/
3741-
wake_up_worker(pwq->pool);
3747+
if (kick)
3748+
wake_up_worker(pwq->pool);
37423749
} else {
37433750
pwq->max_active = 0;
37443751
}

0 commit comments

Comments
 (0)