perf_event: Fix cgrp event scheduling bug in perf_enable_on_exec()
authorStephane Eranian <eranian@google.com>
Wed, 6 Apr 2011 00:54:54 +0000 (02:54 +0200)
committerIngo Molnar <mingo@elte.hu>
Mon, 11 Apr 2011 09:07:55 +0000 (11:07 +0200)
commite566b76ed30768140df8f0023904aed5a41244f7
tree5d8fa756453cb6f60554c6c253a3cf2a01945628
parent621d26567fd0c222f419e3b5ddf39e529e0fdcb3
perf_event: Fix cgrp event scheduling bug in perf_enable_on_exec()

There is a bug in perf_event_enable_on_exec() when cgroup events are
active on a CPU: the cgroup events may be scheduled twice causing event
state corruptions which eventually may lead to kernel panics.

The reason is that the function needs to first schedule out the cgroup
events, just like for the per-thread events. The cgroup event are
scheduled back in automatically from the perf_event_context_sched_in()
function.

The patch also adds a WARN_ON_ONCE() is perf_cgroup_switch() to catch any
bogus state.

Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20110406005454.GA1062@quad
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/perf_event.c