diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2010-05-20 08:35:15 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-05-21 05:37:57 -0400 |
commit | 0f139300c9057c16b5833a4636b715b104fe0baa (patch) | |
tree | e7b19c4fc8599fb683cee1b618b28a8aa16208e2 /kernel | |
parent | 1c024eca51fdc965290acf342ae16a476c2189d0 (diff) |
perf: Ensure that IOC_OUTPUT isn't used to create multi-writer buffers
Since we want to ensure buffers only have a single
writer, we must avoid creating one with multiple.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <20100521090710.528215873@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/perf_event.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 3f2cc313ee25..7a932526946f 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -4920,6 +4920,13 @@ static int perf_event_set_output(struct perf_event *event, int output_fd) | |||
4920 | int fput_needed = 0; | 4920 | int fput_needed = 0; |
4921 | int ret = -EINVAL; | 4921 | int ret = -EINVAL; |
4922 | 4922 | ||
4923 | /* | ||
4924 | * Don't allow output of inherited per-task events. This would | ||
4925 | * create performance issues due to cross cpu access. | ||
4926 | */ | ||
4927 | if (event->cpu == -1 && event->attr.inherit) | ||
4928 | return -EINVAL; | ||
4929 | |||
4923 | if (!output_fd) | 4930 | if (!output_fd) |
4924 | goto set; | 4931 | goto set; |
4925 | 4932 | ||
@@ -4940,6 +4947,18 @@ static int perf_event_set_output(struct perf_event *event, int output_fd) | |||
4940 | if (event->data) | 4947 | if (event->data) |
4941 | goto out; | 4948 | goto out; |
4942 | 4949 | ||
4950 | /* | ||
4951 | * Don't allow cross-cpu buffers | ||
4952 | */ | ||
4953 | if (output_event->cpu != event->cpu) | ||
4954 | goto out; | ||
4955 | |||
4956 | /* | ||
4957 | * If its not a per-cpu buffer, it must be the same task. | ||
4958 | */ | ||
4959 | if (output_event->cpu == -1 && output_event->ctx != event->ctx) | ||
4960 | goto out; | ||
4961 | |||
4943 | atomic_long_inc(&output_file->f_count); | 4962 | atomic_long_inc(&output_file->f_count); |
4944 | 4963 | ||
4945 | set: | 4964 | set: |