perf: Fix a race condition in perf_remove_from_context()
We saw a kernel soft lockup in perf_remove_from_context(),
it looks like the `perf` process, when exiting, could not go
out of the retry loop. Meanwhile, the target process was forking
a child. So either the target process should execute the smp
function call to deactive the event (if it was running) or it should
do a context switch which deactives the event.
It seems we optimize out a context switch in perf_event_context_sched_out(),
and what's more important, we still test an obsolete task pointer when
retrying, so no one actually would deactive that event in this situation.
Fix it directly by reloading the task pointer in perf_remove_from_context().
This should cure the above soft lockup.
Signed-off-by: Cong Wang <email@example.com>
Signed-off-by: Cong Wang <firstname.lastname@example.org>
Signed-off-by: Peter Zijlstra <email@example.com>
Cc: Paul Mackerras <firstname.lastname@example.org>
Cc: Arnaldo Carvalho de Melo <email@example.com>
Cc: Linus Torvalds <firstname.lastname@example.org>
Signed-off-by: Ingo Molnar <email@example.com>
1 file changed