[RFC][PATCH RT 1/4] sched/rt: Fix push_rt_task() to have the same checks as the caller did
From: Steven Rostedt
Date: Fri Dec 07 2012 - 19:09:13 EST
Currently, the push_rt_task() only pushes the task if it is lower
priority than the currently running task.
But this is not the only check. If the currently running task is also
pinned, we may want to push as well, and we do this check when we wake
up a task, but then we are guaranteed to fail pushing the task because
the internal checks may fail.
Make the check the same as the wakeup checks. We could remove the
check in the wake up and just let the push_rt_task() do the work,
but this makes the wake up exit this check on the likely case that
"ok_to_push_task()" will fail, and that we don't need to do the
iterative loop of checks on the pushable task list.
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
Index: linux-rt.git/kernel/sched/rt.c
===================================================================
--- linux-rt.git.orig/kernel/sched/rt.c
+++ linux-rt.git/kernel/sched/rt.c
@@ -1615,6 +1615,15 @@ static struct task_struct *pick_next_pus
return p;
}
+static int ok_to_push_task(struct task_struct *p, struct task_struct *curr)
+{
+ return p->nr_cpus_allowed > 1 &&
+ rt_task(curr) &&
+ (curr->migrate_disable ||
+ curr->nr_cpus_allowed < 2 ||
+ curr->prio <= p->prio);
+}
+
/*
* If the current CPU has more than one RT task, see if the non
* running task can migrate over to a CPU that is running a task
@@ -1649,7 +1658,7 @@ retry:
* higher priority than current. If that's the case
* just reschedule current.
*/
- if (unlikely(next_task->prio < rq->curr->prio)) {
+ if (!ok_to_push_task(next_task, rq->curr)) {
resched_task(rq->curr);
return 0;
}
@@ -1814,10 +1823,7 @@ static void task_woken_rt(struct rq *rq,
if (!task_running(rq, p) &&
!test_tsk_need_resched(rq->curr) &&
has_pushable_tasks(rq) &&
- p->nr_cpus_allowed > 1 &&
- rt_task(rq->curr) &&
- (rq->curr->nr_cpus_allowed < 2 ||
- rq->curr->prio <= p->prio))
+ ok_to_push_task(p, rq->curr))
push_rt_tasks(rq);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/