linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] sched: minimalist select_idle_sibling() bouncing cow syndrome fix
@ 2013-01-27  7:50 Mike Galbraith
  2013-01-28 10:53 ` Ingo Molnar
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Galbraith @ 2013-01-27  7:50 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra


If the previous CPU is cache affine and idle, select it.

Signed-off-by: Mike Galbraith <bitbucket@online.de>
---
 kernel/sched/fair.c |   21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -3270,25 +3270,18 @@ find_idlest_cpu(struct sched_group *grou
  */
 static int select_idle_sibling(struct task_struct *p, int target)
 {
-	int cpu = smp_processor_id();
-	int prev_cpu = task_cpu(p);
 	struct sched_domain *sd;
 	struct sched_group *sg;
-	int i;
+	int i = task_cpu(p);
 
-	/*
-	 * If the task is going to be woken-up on this cpu and if it is
-	 * already idle, then it is the right target.
-	 */
-	if (target == cpu && idle_cpu(cpu))
-		return cpu;
+	if (idle_cpu(target))
+		return target;
 
 	/*
-	 * If the task is going to be woken-up on the cpu where it previously
-	 * ran and if it is currently idle, then it the right target.
+	 * If the prevous cpu is cache affine and idle, don't be stupid.
 	 */
-	if (target == prev_cpu && idle_cpu(prev_cpu))
-		return prev_cpu;
+	if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
+		return i;
 
 	/*
 	 * Otherwise, iterate the domains and find an elegible idle cpu.
@@ -3302,7 +3295,7 @@ static int select_idle_sibling(struct ta
 				goto next;
 
 			for_each_cpu(i, sched_group_cpus(sg)) {
-				if (!idle_cpu(i))
+				if (i == target || !idle_cpu(i))
 					goto next;
 			}
 



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

end of thread, other threads:[~2013-02-04 19:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-27  7:50 [patch] sched: minimalist select_idle_sibling() bouncing cow syndrome fix Mike Galbraith
2013-01-28 10:53 ` Ingo Molnar
2013-01-28 11:19   ` Mike Galbraith
2013-01-28 11:21     ` Ingo Molnar
2013-01-28 11:28       ` Mike Galbraith
2013-02-04 19:25     ` [tip:sched/core] sched: Fix select_idle_sibling() bouncing cow syndrome tip-bot for Mike Galbraith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).