From 9434d607f4ddaf2374dafd86c20ed4336230ecfa Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Mon, 17 Sep 2012 09:57:37 -0400 Subject: Do processor state transitions in schedule_tail(). Fixes a bug in Litmus where processor scheduling states could become corrupted. Corruption can occur when a just-forked thread is externally forced to be scheduled by SCHED_LITMUS before this just-forked thread can complete post-fork processing. Specifically, before schedule_tail() has completed. --- kernel/sched.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/kernel/sched.c b/kernel/sched.c index 2229d0deec4b..65aba7ec564d 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -3163,16 +3163,26 @@ static inline void post_schedule(struct rq *rq) asmlinkage void schedule_tail(struct task_struct *prev) __releases(rq->lock) { - struct rq *rq = this_rq(); - + struct rq *rq; + + preempt_disable(); + + rq = this_rq(); finish_task_switch(rq, prev); + sched_trace_task_switch_to(current); + /* * FIXME: do we need to worry about rq being invalidated by the * task_switch? */ post_schedule(rq); + if (sched_state_validate_switch()) + litmus_reschedule_local(); + + preempt_enable(); + #ifdef __ARCH_WANT_UNLOCKED_CTXSW /* In this case, finish_task_switch does not reenable preemption */ preempt_enable(); -- cgit v1.2.2