[PATCH] Fix race in sched_exit()
From: Martin Schwidefsky <schwidefsky@de.ibm.com> Fix a race on sleep_avg in sched_exit(). The symptom I saw on 64-bit s390 has been a fixpoint divide exception because sleep_avg had a value > NS_MAX_SLEEP_AVG. I tracked it down and the problem is sched_exit which recalculates the parents sleep average without taking the runqueue lock. schedule() subtracts run_time from sleep_avg of the previous process. This can turn out negative and is corrected shortly after the subtraction but that is already too late. sched_exit() already read the negative value an miscalculated the parents sleep_avg -> bang. I fixed this by adding task_rq_lock/task_rq_unlock to sched_exit().
Showing
Please register or sign in to comment