blob: 632dc46db16b5769030ea8d6658a963b17aa99cf [file] [log] [blame]
From 3add58474f5f67c3c53a75aa60ae1d1ee78326e1 Mon Sep 17 00:00:00 2001
From: Carsten Emde <C.Emde@osadl.org>
Date: Mon, 15 Feb 2010 22:30:34 +0100
Subject: [PATCH] sched: Run task on same cpu if idle and allowed
commit 1954630a0637ad1ec2dcfe0324a36cd243f018ee in tip.
The current RT balancer does not consider CPU topology and may
wakeup a process to run on another CPU although it might run
on the current.
This patch adds a check and runs the new task on the current CPU,
if it
- is an RT task,
- is allowed to run on the current CPU, and
- current is not an RT task,
Signed-off-by: Carsten Emde <C.Emde@osadl.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
kernel/sched_rt.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index fdf667b..a1791d7 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -1036,6 +1036,17 @@ static int select_task_rq_rt(struct task_struct *p, int sd_flag, int flags)
}
/*
+ * If the new task is an RT task, current is not an RT task
+ * and the new one may run on the current CPU, run it here.
+ * This avoids sending reschedule IPIs across CPUs.
+ */
+ if (unlikely(rt_task(p)) && !rt_task(rq->curr)) {
+ int cpu = smp_processor_id();
+ if (cpumask_test_cpu(cpu, &p->cpus_allowed))
+ return cpu;
+ }
+
+ /*
* Otherwise, just let it ride on the affined RQ and the
* post-schedule router will push the preempted task away
*/
--
1.7.0.4