summary refs log tree commit diff
path: root/kernel/perf_event.c
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2010-05-18 10:33:24 +0200
committerIngo Molnar <mingo@elte.hu>2010-05-18 18:35:48 +0200
commitc7920614cebbf269a7c8397ff959a8dcf727465c (patch)
treed1ca38ee77cb4160660efb97b8bdc2e5c44967c1 /kernel/perf_event.c
parenta19d35c11fd559dd7dfd5a2078df7c9af74a5d88 (diff)
downloadlinux-c7920614cebbf269a7c8397ff959a8dcf727465c.tar.gz
perf: Disallow mmap() on per-task inherited events
Since we now have working per-task-per-cpu events for
a while, disallow mmap() on per-task inherited
events. Those things were a performance problem
anyway, and doing away with it allows us to optimize
the buffer somewhat by assuming there is only a
single writer.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_event.c')
-rw-r--r--kernel/perf_event.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 6ae62186dd0c..ff5d430d45a7 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -2593,6 +2593,14 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
 	long user_extra, extra;
 	int ret = 0;
 
+	/*
+	 * Don't allow mmap() of inherited per-task counters. This would
+	 * create a performance issue due to all children writing to the
+	 * same buffer.
+	 */
+	if (event->cpu == -1 && event->attr.inherit)
+		return -EINVAL;
+
 	if (!(vma->vm_flags & VM_SHARED))
 		return -EINVAL;