diff options
author | Stephane Eranian <eranian@google.com> | 2010-09-17 05:28:47 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-09-17 06:48:47 -0400 |
commit | d14b12d7adbf214f33eb59f800b5c3d5ed9268e8 (patch) | |
tree | 005705157545c70db6b751f38ae28702714fb1ed /kernel | |
parent | 74704ac6ea402d50c9543cb28247e6d9f521f7ae (diff) |
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: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Robert Richter <robert.richter@amd.com>
LKML-Reference: <20100917093009.360420946@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/perf_event.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index 86f394e15d53..ce95617f5d2c 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -5550,17 +5550,11 @@ SYSCALL_DEFINE5(perf_event_open, | |||
5550 | if (event_fd < 0) | 5550 | if (event_fd < 0) |
5551 | return event_fd; | 5551 | return event_fd; |
5552 | 5552 | ||
5553 | event = perf_event_alloc(&attr, cpu, group_leader, NULL, NULL); | ||
5554 | if (IS_ERR(event)) { | ||
5555 | err = PTR_ERR(event); | ||
5556 | goto err_fd; | ||
5557 | } | ||
5558 | |||
5559 | if (group_fd != -1) { | 5553 | if (group_fd != -1) { |
5560 | group_leader = perf_fget_light(group_fd, &fput_needed); | 5554 | group_leader = perf_fget_light(group_fd, &fput_needed); |
5561 | if (IS_ERR(group_leader)) { | 5555 | if (IS_ERR(group_leader)) { |
5562 | err = PTR_ERR(group_leader); | 5556 | err = PTR_ERR(group_leader); |
5563 | goto err_alloc; | 5557 | goto err_fd; |
5564 | } | 5558 | } |
5565 | group_file = group_leader->filp; | 5559 | group_file = group_leader->filp; |
5566 | if (flags & PERF_FLAG_FD_OUTPUT) | 5560 | if (flags & PERF_FLAG_FD_OUTPUT) |
@@ -5569,6 +5563,12 @@ SYSCALL_DEFINE5(perf_event_open, | |||
5569 | group_leader = NULL; | 5563 | group_leader = NULL; |
5570 | } | 5564 | } |
5571 | 5565 | ||
5566 | event = perf_event_alloc(&attr, cpu, group_leader, NULL, NULL); | ||
5567 | if (IS_ERR(event)) { | ||
5568 | err = PTR_ERR(event); | ||
5569 | goto err_fd; | ||
5570 | } | ||
5571 | |||
5572 | /* | 5572 | /* |
5573 | * Special case software events and allow them to be part of | 5573 | * Special case software events and allow them to be part of |
5574 | * any hardware group. | 5574 | * any hardware group. |
@@ -5653,7 +5653,6 @@ err_context: | |||
5653 | put_ctx(ctx); | 5653 | put_ctx(ctx); |
5654 | err_group_fd: | 5654 | err_group_fd: |
5655 | fput_light(group_file, fput_needed); | 5655 | fput_light(group_file, fput_needed); |
5656 | err_alloc: | ||
5657 | free_event(event); | 5656 | free_event(event); |
5658 | err_fd: | 5657 | err_fd: |
5659 | put_unused_fd(event_fd); | 5658 | put_unused_fd(event_fd); |