perf_event: Switch to internal refcount, fix race with close()
A message that is not in the archive (sent off-list or not yet received): [email protected]
Commit-ID: a6fa941d94b411bbd2b6421ffbde6db3c93e65ab Gitweb: http://git.kernel.org/tip/a6fa941d94b411bbd2b6421ffbde6db3c93e65ab Author: Al Viro <[email protected]> AuthorDate: Mon, 20 Aug 2012 14:59:25 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 4 Sep 2012 17:29:22 +0200
perf_event: Switch to internal refcount, fix race with close()
Don't mess with file refcounts (or keep a reference to file, for that matter) in perf_event. Use explicit refcount of its own instead. Deal with the race between the final reference to event going away and new children getting created for it by use of atomic_long_inc_not_zero() in inherit_event(); just have the latter free what it had allocated and return NULL, that works out just fine (children of siblings of something doomed are created as singletons, same as if the child of leader had been created and immediately killed).
Signed-off-by Al Viro <[email protected]>
Signed-off-by Peter Zijlstra <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
--- include/linux/perf_event.h | 2 +- kernel/events/core.c | 62 +++++++++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 30 deletions(-)
include/linux/perf_event.h +1 -1
@@ -926,7 +926,7 @@ struct perf_event {struct hw_perf_event hw;struct perf_event_context *ctx; -struct file *filp; +atomic_long_t refcount;/* * These accumulate total time (in nanoseconds) that children
kernel/events/core.c +33 -29
160 lines not on this page · raw message