Skip to contentSkip to conversation

perf_events: Fix races and clean up perf_event and perf_mmap_data interaction

tip:perf/urgent tip-bot for Peter Zijlstra 1 participant 1 message May 31, 2010 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  ac9721f3f54b27a16c7e1afb2481e7ee95a70318
Gitweb:     http://git.kernel.org/tip/ac9721f3f54b27a16c7e1afb2481e7ee95a70318
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Thu, 27 May 2010 12:54:41 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 31 May 2010 08:46:08 +0200

perf_events: Fix races and clean up perf_event and perf_mmap_data interaction

In order to move toward separate buffer objects, rework the whole perf_mmap_data construct to be a more self-sufficient entity, one with its own lifetime rules.

This greatly sanitizes the whole output redirection code, which was riddled with bugs and races.

LKML-Reference: <new-submission>

---
 include/linux/perf_event.h |    5 +-
 kernel/perf_event.c        |  224 +++++++++++++++++++++++++-------------------
 2 files changed, 129 insertions(+), 100 deletions(-)
include/linux/perf_event.h +3 -2
index fb6c91e..4906985 100644
@@ -585,6 +585,7 @@ enum perf_event_active_state {
 struct file;
 
 struct perf_mmap_data {
+	atomic_t			refcount;
 	struct rcu_head			rcu_head;
 #ifdef CONFIG_PERF_USE_VMALLOC
 	struct work_struct		work;
@@ -592,7 +593,6 @@ struct perf_mmap_data {
 #endif
 	int				nr_pages;	/* nr of data pages  */
 	int				writable;	/* are we writable   */
-	int				nr_locked;	/* nr pages mlocked  */
 
 	atomic_t			poll;		/* POLL_ for wakeups */
 
@@ -643,7 +643,6 @@ struct perf_event {
 	int				nr_siblings;
 	int				group_flags;
 	struct perf_event		*group_leader;
-	struct perf_event		*output;
 	const struct pmu		*pmu;
 
 	enum perf_event_active_state	state;
@@ -704,6 +703,8 @@ struct perf_event {
 	/* mmap bits */
 	struct mutex			mmap_mutex;
 	atomic_t			mmap_count;
+	int				mmap_locked;
+	struct user_struct		*mmap_user;
 	struct perf_mmap_data		*data;
 
 	/* poll related */
kernel/perf_event.c +126 -98

377 lines not on this page · raw message