[tip: sched/core] sched/core: Make pick_next_task_idle() more consistent
From: tip-bot2 for Peter Zijlstra
Date: Mon Nov 11 2019 - 04:33:16 EST
The following commit has been merged into the sched/core branch of tip:
Commit-ID: f488e1057bb97b881ed317557dc5e62ff8747393
Gitweb: https://git.kernel.org/tip/f488e1057bb97b881ed317557dc5e62ff8747393
Author: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
AuthorDate: Fri, 08 Nov 2019 14:15:56 +01:00
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Mon, 11 Nov 2019 08:35:19 +01:00
sched/core: Make pick_next_task_idle() more consistent
Only pick_next_task_fair() needs the @prev and @rf argument; these are
required to implement the cpu-cgroup optimization. None of the other
pick_next_task() methods need this. Make pick_next_task_idle() more
consistent.
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: bsegall@xxxxxxxxxx
Cc: dietmar.eggemann@xxxxxxx
Cc: juri.lelli@xxxxxxxxxx
Cc: ktkhai@xxxxxxxxxxxxx
Cc: mgorman@xxxxxxx
Cc: qais.yousef@xxxxxxx
Cc: qperret@xxxxxxxxxx
Cc: rostedt@xxxxxxxxxxx
Cc: valentin.schneider@xxxxxxx
Cc: vincent.guittot@xxxxxxxxxx
Link: https://lkml.kernel.org/r/20191108131909.545730862@xxxxxxxxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
kernel/sched/core.c | 6 ++++--
kernel/sched/idle.c | 3 +--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 0f2eb36..59c4f29 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3922,8 +3922,10 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
goto restart;
/* Assumes fair_sched_class->next == idle_sched_class */
- if (unlikely(!p))
- p = idle_sched_class.pick_next_task(rq, prev, rf);
+ if (unlikely(!p)) {
+ put_prev_task(rq, prev);
+ p = idle_sched_class.pick_next_task(rq, NULL, NULL);
+ }
return p;
}
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index f65ef1e..179d1d4 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -396,8 +396,7 @@ pick_next_task_idle(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
{
struct task_struct *next = rq->idle;
- if (prev)
- put_prev_task(rq, prev);
+ WARN_ON_ONCE(prev || rf);
set_next_task_idle(rq, next);