public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] sched: Avoid select_idle_sibling() for wake_affine(.sync=true)
@ 2013-09-25  7:53 Peter Zijlstra
  2013-09-25  8:56 ` Mike Galbraith
  0 siblings, 1 reply; 21+ messages in thread
From: Peter Zijlstra @ 2013-09-25  7:53 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Mike Galbraith, Paul Turner, Rik van Riel, linux-kernel

Subject: sched: Avoid select_idle_sibling() for wake_affine(.sync=true)
From: Peter Zijlstra <peterz@infradead.org>
Date: Wed Sep 25 08:28:39 CEST 2013

When a task is the only running task and does a sync wakeup; avoid
going through select_idle_sibling() as it doesn't know the current CPU
is going to be idle shortly.

Without this two sync wakers will ping-pong between CPUs for no
reason.

Suggested-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
---
 kernel/sched/fair.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3461,6 +3461,16 @@ select_task_rq_fair(struct task_struct *
 		if (cpu != prev_cpu && wake_affine(affine_sd, p, sync))
 			prev_cpu = cpu;
 
+		/*
+		 * Don't bother with select_idle_sibling() in the case of a sync wakeup
+		 * where we know the only running task will soon go away. Going
+		 * through select_idle_sibling will only lead to pointless ping-pong.
+		 */
+		if (sync && prev_cpu == cpu && cpu_rq(cpu)->nr_running == 1) {
+			new_cpu = cpu;
+			goto unlock;
+		}
+
 		new_cpu = select_idle_sibling(p, prev_cpu);
 		goto unlock;
 	}

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2013-09-27  1:19 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-25  7:53 [RFC][PATCH] sched: Avoid select_idle_sibling() for wake_affine(.sync=true) Peter Zijlstra
2013-09-25  8:56 ` Mike Galbraith
2013-09-26  2:50   ` Michael wang
2013-09-26  3:41     ` Mike Galbraith
2013-09-26  5:12       ` Michael wang
2013-09-26  5:34         ` Mike Galbraith
2013-09-26  6:15           ` Mike Galbraith
2013-09-26  6:32           ` Michael wang
2013-09-26  7:09             ` Mike Galbraith
2013-09-26  7:26               ` Michael wang
2013-09-26  9:58   ` Peter Zijlstra
2013-09-26 10:05     ` Peter Zijlstra
2013-09-26 10:55     ` Paul Turner
2013-09-26 11:16       ` Peter Zijlstra
2013-09-26 11:39         ` Paul Turner
2013-09-26 14:35           ` Peter Zijlstra
2013-09-26 15:43             ` Peter Zijlstra
2013-09-26 13:46     ` Mike Galbraith
2013-09-26 15:09     ` Michael wang
2013-09-26 15:44       ` Peter Zijlstra
2013-09-27  1:19         ` Michael wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox