| From 1954630a0637ad1ec2dcfe0324a36cd243f018ee 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> |
| |
| diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c |
| index 7a27ef6..9de5f18 100644 |
| --- a/kernel/sched_rt.c |
| +++ b/kernel/sched_rt.c |
| @@ -1030,6 +1030,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.1.1 |
| |