aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/events
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2014-05-06 03:59:34 -0400
committerIngo Molnar <mingo@kernel.org>2014-05-07 07:44:17 -0400
commit1f4ee5038f0c1ef95f8e6d47ad6623e006b5bce1 (patch)
treebaeeb3164bca54b629b1b41a6ee93234749c9ea5 /kernel/events
parent37b16beaa92860c378273ccdcc2ccb22c6cee047 (diff)
perf: Ensure consistent inherit state in groups
Make sure all events in a group have the same inherit state. It was possible for group leaders to have inherit set while sibling events would not have inherit set. In this case we'd still inherit the siblings, leading to some non-fatal weirdness. Signed-off-by: Peter Zijlstra <peterz@infradead.org> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Vince Weaver <vincent.weaver@maine.edu> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-r32tt8yldvic3jlcghd3g35u@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel/events')
-rw-r--r--kernel/events/core.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 09866a330af8..1de0d709f69f 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7081,20 +7081,26 @@ SYSCALL_DEFINE5(perf_event_open,
7081 } 7081 }
7082 } 7082 }
7083 7083
7084 if (task && group_leader &&
7085 group_leader->attr.inherit != attr.inherit) {
7086 err = -EINVAL;
7087 goto err_task;
7088 }
7089
7084 get_online_cpus(); 7090 get_online_cpus();
7085 7091
7086 event = perf_event_alloc(&attr, cpu, task, group_leader, NULL, 7092 event = perf_event_alloc(&attr, cpu, task, group_leader, NULL,
7087 NULL, NULL); 7093 NULL, NULL);
7088 if (IS_ERR(event)) { 7094 if (IS_ERR(event)) {
7089 err = PTR_ERR(event); 7095 err = PTR_ERR(event);
7090 goto err_task; 7096 goto err_cpus;
7091 } 7097 }
7092 7098
7093 if (flags & PERF_FLAG_PID_CGROUP) { 7099 if (flags & PERF_FLAG_PID_CGROUP) {
7094 err = perf_cgroup_connect(pid, event, &attr, group_leader); 7100 err = perf_cgroup_connect(pid, event, &attr, group_leader);
7095 if (err) { 7101 if (err) {
7096 __free_event(event); 7102 __free_event(event);
7097 goto err_task; 7103 goto err_cpus;
7098 } 7104 }
7099 } 7105 }
7100 7106
@@ -7256,8 +7262,9 @@ err_context:
7256 put_ctx(ctx); 7262 put_ctx(ctx);
7257err_alloc: 7263err_alloc:
7258 free_event(event); 7264 free_event(event);
7259err_task: 7265err_cpus:
7260 put_online_cpus(); 7266 put_online_cpus();
7267err_task:
7261 if (task) 7268 if (task)
7262 put_task_struct(task); 7269 put_task_struct(task);
7263err_group_fd: 7270err_group_fd: