diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2010-10-14 10:59:46 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-10-18 13:58:54 -0400 |
commit | c6be5a5cb62592d9d661899a2aa78236eb00ffa5 (patch) | |
tree | 510a7b92a65a2faf7395f6ab37be44328f0186cf /kernel | |
parent | e7d0bc047548d76feee6b23f7d3d9da927189a50 (diff) |
perf: Find task before event alloc
So that we can pass the task pointer to the event allocation, so that
we can use task associated data during event initialization.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20101014203625.340789919@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/perf_event.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index f928878a1c17..b21d06aaef60 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -5551,10 +5551,18 @@ SYSCALL_DEFINE5(perf_event_open, | |||
5551 | group_leader = NULL; | 5551 | group_leader = NULL; |
5552 | } | 5552 | } |
5553 | 5553 | ||
5554 | if (pid != -1) { | ||
5555 | task = find_lively_task_by_vpid(pid); | ||
5556 | if (IS_ERR(task)) { | ||
5557 | err = PTR_ERR(task); | ||
5558 | goto err_group_fd; | ||
5559 | } | ||
5560 | } | ||
5561 | |||
5554 | event = perf_event_alloc(&attr, cpu, group_leader, NULL, NULL); | 5562 | event = perf_event_alloc(&attr, cpu, group_leader, NULL, NULL); |
5555 | if (IS_ERR(event)) { | 5563 | if (IS_ERR(event)) { |
5556 | err = PTR_ERR(event); | 5564 | err = PTR_ERR(event); |
5557 | goto err_fd; | 5565 | goto err_task; |
5558 | } | 5566 | } |
5559 | 5567 | ||
5560 | /* | 5568 | /* |
@@ -5586,21 +5594,13 @@ SYSCALL_DEFINE5(perf_event_open, | |||
5586 | } | 5594 | } |
5587 | } | 5595 | } |
5588 | 5596 | ||
5589 | if (pid != -1) { | ||
5590 | task = find_lively_task_by_vpid(pid); | ||
5591 | if (IS_ERR(task)) { | ||
5592 | err = PTR_ERR(task); | ||
5593 | goto err_group_fd; | ||
5594 | } | ||
5595 | } | ||
5596 | |||
5597 | /* | 5597 | /* |
5598 | * Get the target context (task or percpu): | 5598 | * Get the target context (task or percpu): |
5599 | */ | 5599 | */ |
5600 | ctx = find_get_context(pmu, task, cpu); | 5600 | ctx = find_get_context(pmu, task, cpu); |
5601 | if (IS_ERR(ctx)) { | 5601 | if (IS_ERR(ctx)) { |
5602 | err = PTR_ERR(ctx); | 5602 | err = PTR_ERR(ctx); |
5603 | goto err_task; | 5603 | goto err_alloc; |
5604 | } | 5604 | } |
5605 | 5605 | ||
5606 | /* | 5606 | /* |
@@ -5696,12 +5696,13 @@ SYSCALL_DEFINE5(perf_event_open, | |||
5696 | 5696 | ||
5697 | err_context: | 5697 | err_context: |
5698 | put_ctx(ctx); | 5698 | put_ctx(ctx); |
5699 | err_alloc: | ||
5700 | free_event(event); | ||
5699 | err_task: | 5701 | err_task: |
5700 | if (task) | 5702 | if (task) |
5701 | put_task_struct(task); | 5703 | put_task_struct(task); |
5702 | err_group_fd: | 5704 | err_group_fd: |
5703 | fput_light(group_file, fput_needed); | 5705 | fput_light(group_file, fput_needed); |
5704 | free_event(event); | ||
5705 | err_fd: | 5706 | err_fd: |
5706 | put_unused_fd(event_fd); | 5707 | put_unused_fd(event_fd); |
5707 | return err; | 5708 | return err; |