perf_events: Fix races in group composition
Commit-ID: 8a49542c0554af7d0073aac0ee73ee65b807ef34 Gitweb: http://git.kernel.org/tip/8a49542c0554af7d0073aac0ee73ee65b807ef34 Author: Peter Zijlstra <[email protected]> AuthorDate: Thu, 27 May 2010 15:47:49 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 31 May 2010 08:46:09 +0200
perf_events: Fix races in group composition
Group siblings don't pin each-other or the parent, so when we destroy events we must make sure to clean up all cross referencing pointers.
In particular, for destruction of a group leader we must be able to find all its siblings and remove their reference to it.
This means that detaching an event from its context must not detach it from the group, otherwise we can end up failing to clear all pointers.
Solve this by clearly separating the attachment to a context and attachment to a group, and keep the group composed until we destroy the events.
Signed-off-by Peter Zijlstra <[email protected]>
LKML-Reference: <new-submission>
Signed-off-by Ingo Molnar <[email protected]>
--- include/linux/perf_event.h | 4 ++ kernel/perf_event.c | 91 ++++++++++++++++++++++++++++++++----------- 2 files changed, 71 insertions(+), 24 deletions(-)
include/linux/perf_event.h +4 -0
@@ -631,6 +631,9 @@ struct swevent_hlist {struct rcu_head rcu_head; }; +#define PERF_ATTACH_CONTEXT 0x01 +#define PERF_ATTACH_GROUP 0x02 +/** * struct perf_event - performance event kernel representation: */
@@ -646,6 +649,7 @@ struct perf_event {const struct pmu *pmu;enum perf_event_active_state state; +unsigned int attach_state;atomic64_t count;/*
kernel/perf_event.c +67 -24
164 lines not on this page · raw message