Skip to content

Commit

Permalink
perf_events: Fix races and clean up perf_event and perf_mmap_data int…
Browse files Browse the repository at this point in the history
…eraction

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.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: <stable@kernel.org>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed May 31, 2010
1 parent 67a3e12 commit ac9721f
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 100 deletions.
5 changes: 3 additions & 2 deletions include/linux/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,14 +585,14 @@ 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;
int page_order; /* allocation order */
#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 */

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
Loading

0 comments on commit ac9721f

Please sign in to comment.