Skip to content

Commit

Permalink
sched: Reassign prev and switch_count when reacquire_kernel_lock() fail
Browse files Browse the repository at this point in the history
Assume A->B schedule is processing, if B have acquired BKL before and it
need reschedule this time. Then on B's context, it will go to
need_resched_nonpreemptible for reschedule. But at this time, prev and
switch_count are related to A. It's wrong and will lead to incorrect
scheduler statistics.

Signed-off-by: Yong Zhang <[email protected]>
Signed-off-by: Peter Zijlstra <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
yongzhang0 authored and Ingo Molnar committed Jan 21, 2010
1 parent 50b926e commit 6d558c3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -5530,8 +5530,11 @@ asmlinkage void __sched schedule(void)

post_schedule(rq);

if (unlikely(reacquire_kernel_lock(current) < 0))
if (unlikely(reacquire_kernel_lock(current) < 0)) {
prev = rq->curr;
switch_count = &prev->nivcsw;
goto need_resched_nonpreemptible;
}

preempt_enable_no_resched();
if (need_resched())
Expand Down

0 comments on commit 6d558c3

Please sign in to comment.