perf_counter: Robustify counter-free logic
Commit-ID: 012b84dae17126d8b5d159173091eb3db5a2bc43 Gitweb: http://git.kernel.org/tip/012b84dae17126d8b5d159173091eb3db5a2bc43 Author: Ingo Molnar <[email protected]> AuthorDate: Sun, 17 May 2009 11:08:41 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 29 May 2009 14:28:37 +0200
perf_counter: Robustify counter-free logic
This fixes a nasty crash and highlights a bug that we were freeing failed-fork() counters incorrectly.
(the fix for that will come separately)
[ Impact: fix crashes/lockups with inherited counters ]
Acked-by Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Corey Ashford <[email protected]>
Cc Marcelo Tosatti <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc John Kacur <[email protected]>
LKML-Reference: <new-submission>
Signed-off-by Ingo Molnar <[email protected]>
--- kernel/perf_counter.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
kernel/perf_counter.c +4 -0
@@ -1004,6 +1004,10 @@ static void __perf_counter_task_sched_out(struct perf_counter_context *ctx)if (!cpuctx->task_ctx)return ; + +if (WARN_ON_ONCE (ctx != cpuctx->task_ctx)) +return ; +__perf_counter_sched_out (ctx, cpuctx); cpuctx->task_ctx =NULL ; }