summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2014-01-17 17:43:29 +0100
committerDaniel Lezcano <daniel.lezcano@linaro.org>2014-02-06 11:13:30 +0000
commit0c4af86139bea0ac2a9df3ae4ecfbe8e988717e0 (patch)
treed17c79b6209bdd8e8948333c9909420c20ac0dab
parent379a0c9a20dc2b9be81bfc1a581737227a7b29e2 (diff)
sched: Use idle task shortcut
With the previous patches, we have no ambiguity on going to idle. So we can return directly the idle task instead of looking up all the domains which will in any case return the idle_task. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r--kernel/sched/core.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index aa30f1121c38..20afafc150b5 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2588,23 +2588,35 @@ pick_next_task(struct rq *rq, struct task_struct *prev)
const struct sched_class *class;
struct task_struct *p;
- /*
- * Optimization: we know that if all tasks are in
- * the fair class we can call that function directly:
- */
- if (likely(rq->nr_running == rq->cfs.h_nr_running)) {
- p = fair_sched_class.pick_next_task(rq, prev);
- if (likely(p))
- return p;
+again:
+ if (likely(rq->nr_running)) {
+ /*
+ * Optimization: we know that if all tasks are in
+ * the fair class we can call that function directly:
+ */
+ if (likely(rq->nr_running == rq->cfs.h_nr_running))
+ return fair_sched_class.pick_next_task(rq, prev);
+
+ for_each_class(class) {
+ p = class->pick_next_task(rq, prev);
+ if (p)
+ return p;
+ }
}
- for_each_class(class) {
- p = class->pick_next_task(rq, prev);
- if (p)
- return p;
+ rq->idle_stamp = rq_clock(rq);
+
+ /*
+ * If there is a task balanced on this cpu, pick the next task,
+ * otherwise fall in the optimization by picking the idle task
+ * directly.
+ */
+ if (idle_balance(rq)) {
+ rq->idle_stamp = 0;
+ goto again;
}
- BUG(); /* the idle class will always have a runnable task */
+ return idle_sched_class.pick_next_task(rq, prev);
}
/*
@@ -2697,14 +2709,6 @@ need_resched:
pre_schedule(rq, prev);
-#ifdef CONFIG_SMP
- if (unlikely(!rq->nr_running)) {
- rq->idle_stamp = rq_clock(rq);
- if (idle_balance(rq))
- rq->idle_stamp = 0;
- }
-#endif
-
if (prev->on_rq || rq->skip_clock_update < 0)
update_rq_clock(rq);