diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2011-03-15 09:37:10 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-03-16 09:04:14 -0400 |
commit | 38b435b16c36b0d863efcf3f07b34a6fac9873fd (patch) | |
tree | 017a36f9883767175f8018f43fac937a9fc22a24 /kernel/perf_event.c | |
parent | ee643c4179c3a18b018de3a4c07a7bb3a75c8e4e (diff) |
perf: Fix tear-down of inherited group events
When destroying inherited events, we need to destroy groups too,
otherwise the event iteration in perf_event_exit_task_context() will
miss group siblings and we leak events with all the consequences.
Reported-and-tested-by: Vince Weaver <vweaver1@eecs.utk.edu>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: <stable@kernel.org> # .35+
LKML-Reference: <1300196470.2203.61.camel@twins>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_event.c')
-rw-r--r-- | kernel/perf_event.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 533f71570736..3472bb1a070c 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -6722,17 +6722,20 @@ __perf_event_exit_task(struct perf_event *child_event, | |||
6722 | struct perf_event_context *child_ctx, | 6722 | struct perf_event_context *child_ctx, |
6723 | struct task_struct *child) | 6723 | struct task_struct *child) |
6724 | { | 6724 | { |
6725 | struct perf_event *parent_event; | 6725 | if (child_event->parent) { |
6726 | raw_spin_lock_irq(&child_ctx->lock); | ||
6727 | perf_group_detach(child_event); | ||
6728 | raw_spin_unlock_irq(&child_ctx->lock); | ||
6729 | } | ||
6726 | 6730 | ||
6727 | perf_remove_from_context(child_event); | 6731 | perf_remove_from_context(child_event); |
6728 | 6732 | ||
6729 | parent_event = child_event->parent; | ||
6730 | /* | 6733 | /* |
6731 | * It can happen that parent exits first, and has events | 6734 | * It can happen that the parent exits first, and has events |
6732 | * that are still around due to the child reference. These | 6735 | * that are still around due to the child reference. These |
6733 | * events need to be zapped - but otherwise linger. | 6736 | * events need to be zapped. |
6734 | */ | 6737 | */ |
6735 | if (parent_event) { | 6738 | if (child_event->parent) { |
6736 | sync_child_event(child_event, child); | 6739 | sync_child_event(child_event, child); |
6737 | free_event(child_event); | 6740 | free_event(child_event); |
6738 | } | 6741 | } |