Commit 49ee5768 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

sched/core: Optimize pick_next_task() for idle_sched_class

Steve noticed that when we switch from IDLE to SCHED_OTHER we fail to
take the shortcut, even though all runnable tasks are of the fair
class, because prev->sched_class != &fair_sched_class.

Since I reworked the put_prev_task() stuff, we don't really care about
prev->class here, so removing that condition will allow this case.

This increases the likely case from 78% to 98% correct for Steve's
workload.
Reported-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Tested-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20170119174408.GN6485@twins.programming.kicks-ass.netSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 3a09b8d4
...@@ -3321,15 +3321,14 @@ static inline void schedule_debug(struct task_struct *prev) ...@@ -3321,15 +3321,14 @@ static inline void schedule_debug(struct task_struct *prev)
static inline struct task_struct * static inline struct task_struct *
pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
{ {
const struct sched_class *class = &fair_sched_class; const struct sched_class *class;
struct task_struct *p; struct task_struct *p;
/* /*
* Optimization: we know that if all tasks are in * Optimization: we know that if all tasks are in
* the fair class we can call that function directly: * the fair class we can call that function directly:
*/ */
if (likely(prev->sched_class == class && if (likely(rq->nr_running == rq->cfs.h_nr_running)) {
rq->nr_running == rq->cfs.h_nr_running)) {
p = fair_sched_class.pick_next_task(rq, prev, rf); p = fair_sched_class.pick_next_task(rq, prev, rf);
if (unlikely(p == RETRY_TASK)) if (unlikely(p == RETRY_TASK))
goto again; goto again;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment