sched: Give CPU bound RT tasks preference
authorSteven Rostedt <srostedt@redhat.com>
Tue, 21 Sep 2010 02:40:04 +0000 (22:40 -0400)
committerIngo Molnar <mingo@elte.hu>
Tue, 21 Sep 2010 11:57:12 +0000 (13:57 +0200)
If a high priority task is waking up on a CPU that is running a
lower priority task that is bound to a CPU, see if we can move the
high RT task to another CPU first. Note, if all other CPUs are
running higher priority tasks than the CPU bounded current task,
then it will be preempted regardless.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Gregory Haskins <ghaskins@novell.com>
LKML-Reference: <20100921024138.888922071@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/sched_rt.c

index 6a02b38ab653cfc226ff96a07c5ecdd5e2a19c9f..baef30f08405560d56bbe930bf366bd56eef5ef7 100644 (file)
@@ -971,7 +971,8 @@ select_task_rq_rt(struct rq *rq, struct task_struct *p, int sd_flag, int flags)
         * For equal prio tasks, we just let the scheduler sort it out.
         */
        if (unlikely(rt_task(rq->curr)) &&
-           rq->curr->prio < p->prio &&
+           (rq->curr->rt.nr_cpus_allowed < 2 ||
+            rq->curr->prio < p->prio) &&
            (p->rt.nr_cpus_allowed > 1)) {
                int cpu = find_lowest_rq(p);
 
@@ -1491,9 +1492,10 @@ static void task_woken_rt(struct rq *rq, struct task_struct *p)
        if (!task_running(rq, p) &&
            !test_tsk_need_resched(rq->curr) &&
            has_pushable_tasks(rq) &&
+           p->rt.nr_cpus_allowed > 1 &&
            rt_task(rq->curr) &&
-           rq->curr->prio < p->prio &&
-           p->rt.nr_cpus_allowed > 1)
+           (rq->curr->rt.nr_cpus_allowed < 2 ||
+            rq->curr->prio < p->prio))
                push_rt_tasks(rq);
 }