diff options
author | Carsten Emde <C.Emde@osadl.org> | 2010-02-15 22:30:34 +0100 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2010-02-21 20:20:12 +0100 |
commit | 1954630a0637ad1ec2dcfe0324a36cd243f018ee (patch) | |
tree | 2203e64b007c232a5a7f8d302572eb2c025e6054 | |
parent | 28bbb2398ebbeac1d4c1fd109938441842c8f89e (diff) | |
download | lwn-1954630a0637ad1ec2dcfe0324a36cd243f018ee.tar.gz lwn-1954630a0637ad1ec2dcfe0324a36cd243f018ee.zip |
sched: Run task on same cpu if idle and allowed
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>
-rw-r--r-- | 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 7a27ef6308c0..9de5f18b92bf 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 */ |