提交 d14b12d7 编写于 作者: S Stephane Eranian 提交者: Ingo Molnar

perf_events: Fix broken event grouping

Events were not grouped anymore. The reason was that in
perf_event_open(), the field event->group_leader was
initialized before the function looked up the group_fd
to find the event leader. This patch fixes this by
reordering the code correctly.
Signed-off-by: NStephane Eranian <eranian@google.com>
Signed-off-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Robert Richter <robert.richter@amd.com>
LKML-Reference: <20100917093009.360420946@chello.nl>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 74704ac6
...@@ -5550,17 +5550,11 @@ SYSCALL_DEFINE5(perf_event_open, ...@@ -5550,17 +5550,11 @@ SYSCALL_DEFINE5(perf_event_open,
if (event_fd < 0) if (event_fd < 0)
return event_fd; return event_fd;
event = perf_event_alloc(&attr, cpu, group_leader, NULL, NULL);
if (IS_ERR(event)) {
err = PTR_ERR(event);
goto err_fd;
}
if (group_fd != -1) { if (group_fd != -1) {
group_leader = perf_fget_light(group_fd, &fput_needed); group_leader = perf_fget_light(group_fd, &fput_needed);
if (IS_ERR(group_leader)) { if (IS_ERR(group_leader)) {
err = PTR_ERR(group_leader); err = PTR_ERR(group_leader);
goto err_alloc; goto err_fd;
} }
group_file = group_leader->filp; group_file = group_leader->filp;
if (flags & PERF_FLAG_FD_OUTPUT) if (flags & PERF_FLAG_FD_OUTPUT)
...@@ -5569,6 +5563,12 @@ SYSCALL_DEFINE5(perf_event_open, ...@@ -5569,6 +5563,12 @@ SYSCALL_DEFINE5(perf_event_open,
group_leader = NULL; group_leader = NULL;
} }
event = perf_event_alloc(&attr, cpu, group_leader, NULL, NULL);
if (IS_ERR(event)) {
err = PTR_ERR(event);
goto err_fd;
}
/* /*
* Special case software events and allow them to be part of * Special case software events and allow them to be part of
* any hardware group. * any hardware group.
...@@ -5653,7 +5653,6 @@ SYSCALL_DEFINE5(perf_event_open, ...@@ -5653,7 +5653,6 @@ SYSCALL_DEFINE5(perf_event_open,
put_ctx(ctx); put_ctx(ctx);
err_group_fd: err_group_fd:
fput_light(group_file, fput_needed); fput_light(group_file, fput_needed);
err_alloc:
free_event(event); free_event(event);
err_fd: err_fd:
put_unused_fd(event_fd); put_unused_fd(event_fd);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册