History

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.

Yunfeng Ye committed 5 years ago

Commit 01341fb1 parent 127c5011 file · +10 −3Browse files

Showing the changes to kernel/workqueue.c (1 of 1 file). Show all

Unified · Split

kernel/workqueue.c+10−3
@@ -3728,17 +3728,24 @@ static void pwq_adjust_max_active(struct pool_workqueue *pwq) · 3727 unmodified lines
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 }