Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e3e4b33 authored by Yunfeng Ye's avatar Yunfeng Ye Committed by Greg Kroah-Hartman
Browse files

workqueue: Kick a worker based on the actual activation of delayed works



[ Upstream commit 01341fbd0d8d4e717fc1231cdffe00343088ce0b ]

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: default avatarYunfeng Ye <yeyunfeng@huawei.com>
Reviewed-by: default avatarLai Jiangshan <jiangshanlai@gmail.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent ccf4f293
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -3554,16 +3554,23 @@ static void pwq_adjust_max_active(struct pool_workqueue *pwq)
	 * is updated and visible.
	 * is updated and visible.
	 */
	 */
	if (!freezable || !workqueue_freezing) {
	if (!freezable || !workqueue_freezing) {
		bool kick = false;

		pwq->max_active = wq->saved_max_active;
		pwq->max_active = wq->saved_max_active;


		while (!list_empty(&pwq->delayed_works) &&
		while (!list_empty(&pwq->delayed_works) &&
		       pwq->nr_active < pwq->max_active)
		       pwq->nr_active < pwq->max_active) {
			pwq_activate_first_delayed(pwq);
			pwq_activate_first_delayed(pwq);
			kick = true;
		}


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