aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched/core.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2014-10-08 15:36:44 -0400
committerIngo Molnar <mingo@kernel.org>2014-10-28 05:47:54 -0400
commit1a43a14a5bd9c32dbd7af35e35a5afa703944bcb (patch)
treedbbef5740b8e0851eef0c19760e548529076613c /kernel/sched/core.c
parent8f9fbf092cd0ae31722b42c9abb427a87d55c18a (diff)
sched: Fix schedule_tail() to disable preemption
finish_task_switch() enables preemption, so post_schedule(rq) can be called on the wrong (and even dead) CPU. Afaics, nothing really bad can happen, but in this case we can wrongly clear rq->post_schedule on that CPU. And this simply looks wrong in any case. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Kirill Tkhai <tkhai@yandex.ru> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: http://lkml.kernel.org/r/20141008193644.GA32055@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/sched/core.c')
-rw-r--r--kernel/sched/core.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index cde848149dd6..b4935600cd85 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2309,15 +2309,14 @@ static inline void post_schedule(struct rq *rq)
2309asmlinkage __visible void schedule_tail(struct task_struct *prev) 2309asmlinkage __visible void schedule_tail(struct task_struct *prev)
2310 __releases(rq->lock) 2310 __releases(rq->lock)
2311{ 2311{
2312 struct rq *rq = this_rq(); 2312 struct rq *rq;
2313 2313
2314 /* finish_task_switch() drops rq->lock and enables preemtion */
2315 preempt_disable();
2316 rq = this_rq();
2314 finish_task_switch(rq, prev); 2317 finish_task_switch(rq, prev);
2315
2316 /*
2317 * FIXME: do we need to worry about rq being invalidated by the
2318 * task_switch?
2319 */
2320 post_schedule(rq); 2318 post_schedule(rq);
2319 preempt_enable();
2321 2320
2322 if (current->set_child_tid) 2321 if (current->set_child_tid)
2323 put_user(task_pid_vnr(current), current->set_child_tid); 2322 put_user(task_pid_vnr(current), current->set_child_tid);