summaryrefslogtreecommitdiffstats
path: root/kernel/sched/stop_task.c
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2014-02-12 10:49:30 +0100
committerThomas Gleixner <tglx@linutronix.de>2014-02-21 21:43:18 +0100
commit3f1d2a318171bf61850d4e5a72031271e5aada76 (patch)
tree58b0fe5519ddeaac88983ff2ba9818f8695db726 /kernel/sched/stop_task.c
parent6e83125c6b151afa139c8852c099d6d92954fe3b (diff)
downloadlinux-stable-3f1d2a318171bf61850d4e5a72031271e5aada76.tar.gz
linux-stable-3f1d2a318171bf61850d4e5a72031271e5aada76.tar.bz2
linux-stable-3f1d2a318171bf61850d4e5a72031271e5aada76.zip
sched: Fix hotplug task migration
Dan Carpenter reported: > kernel/sched/rt.c:1347 pick_next_task_rt() warn: variable dereferenced before check 'prev' (see line 1338) > kernel/sched/deadline.c:1011 pick_next_task_dl() warn: variable dereferenced before check 'prev' (see line 1005) Kirill also spotted that migrate_tasks() will have an instant NULL deref because pick_next_task() will immediately deref prev. Instead of fixing all the corner cases because migrate_tasks() can pass in a NULL prev task in the unlikely case of hot-un-plug, provide a fake task such that we can remove all the NULL checks from the far more common paths. A further problem; not previously spotted; is that because we pushed pre_schedule() and idle_balance() into pick_next_task() we now need to avoid those getting called and pulling more tasks on our dying CPU. We avoid pull_{dl,rt}_task() by setting fake_task.prio to MAX_PRIO+1. We also note that since we call pick_next_task() exactly the amount of times we have runnable tasks present, we should never land in idle_balance(). Fixes: 38033c37faab ("sched: Push down pre_schedule() and idle_balance()") Cc: Juri Lelli <juri.lelli@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Steven Rostedt <rostedt@goodmis.org> Reported-by: Kirill Tkhai <tkhai@yandex.ru> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20140212094930.GB3545@laptop.programming.kicks-ass.net Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/sched/stop_task.c')
-rw-r--r--kernel/sched/stop_task.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/kernel/sched/stop_task.c b/kernel/sched/stop_task.c
index a4147c9d2017..d6ce65dde541 100644
--- a/kernel/sched/stop_task.c
+++ b/kernel/sched/stop_task.c
@@ -31,8 +31,7 @@ pick_next_task_stop(struct rq *rq, struct task_struct *prev)
if (!stop || !stop->on_rq)
return NULL;
- if (prev)
- prev->sched_class->put_prev_task(rq, prev);
+ put_prev_task(rq, prev);
stop->se.exec_start = rq_clock_task(rq);