From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Ingo Molnar <mingo@elte.hu>,
Frederic Weisbecker <fweisbec@gmail.com>,
Jason Baron <jbaron@redhat.com>
Cc: linux-kernel@vger.kernel.org, David Miller <davem@davemloft.net>,
Mike Galbraith <efault@gmx.de>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [RFC][PATCH 2/7] perf: Find task before event alloc
Date: Thu, 14 Oct 2010 22:34:06 +0200 [thread overview]
Message-ID: <20101014203625.340789919@chello.nl> (raw)
In-Reply-To: 20101014203404.222133139@chello.nl
[-- Attachment #1: perf-fix-hw_bp-1.patch --]
[-- Type: text/plain, Size: 1561 bytes --]
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>
---
kernel/perf_event.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
Index: linux-2.6/kernel/perf_event.c
===================================================================
--- linux-2.6.orig/kernel/perf_event.c
+++ linux-2.6/kernel/perf_event.c
@@ -5485,10 +5485,18 @@ SYSCALL_DEFINE5(perf_event_open,
group_leader = NULL;
}
+ if (pid != -1) {
+ task = find_lively_task_by_vpid(pid);
+ if (IS_ERR(task)) {
+ err = PTR_ERR(task);
+ goto err_group_fd;
+ }
+ }
+
event = perf_event_alloc(&attr, cpu, group_leader, NULL, NULL);
if (IS_ERR(event)) {
err = PTR_ERR(event);
- goto err_fd;
+ goto err_task;
}
/*
@@ -5520,21 +5528,13 @@ SYSCALL_DEFINE5(perf_event_open,
}
}
- if (pid != -1) {
- task = find_lively_task_by_vpid(pid);
- if (IS_ERR(task)) {
- err = PTR_ERR(task);
- goto err_group_fd;
- }
- }
-
/*
* Get the target context (task or percpu):
*/
ctx = find_get_context(pmu, task, cpu);
if (IS_ERR(ctx)) {
err = PTR_ERR(ctx);
- goto err_task;
+ goto err_alloc;
}
/*
@@ -5630,12 +5630,13 @@ SYSCALL_DEFINE5(perf_event_open,
err_context:
put_ctx(ctx);
+err_alloc:
+ free_event(event);
err_task:
if (task)
put_task_struct(task);
err_group_fd:
fput_light(group_file, fput_needed);
- free_event(event);
err_fd:
put_unused_fd(event_fd);
return err;
next prev parent reply other threads:[~2010-10-14 21:10 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-14 20:34 [RFC][PATCH 0/7] perf and jump_label bits Peter Zijlstra
2010-10-14 20:34 ` [RFC][PATCH 1/7] perf: Fix task refcount issues Peter Zijlstra
2010-10-15 18:14 ` Frederic Weisbecker
2010-10-15 20:02 ` Matt Helsley
2010-10-18 19:19 ` [tip:perf/core] perf: Fix task refcount bugs tip-bot for Peter Zijlstra
2010-10-14 20:34 ` Peter Zijlstra [this message]
2010-10-18 19:20 ` [tip:perf/core] perf: Find task before event alloc tip-bot for Peter Zijlstra
2010-10-14 20:34 ` [RFC][PATCH 3/7] perf, hw_breakpoint: Fix crash in hw_breakpoint creation Peter Zijlstra
2010-10-15 13:47 ` Frederic Weisbecker
2010-10-15 13:52 ` Peter Zijlstra
2010-10-18 19:20 ` [tip:perf/core] " tip-bot for Peter Zijlstra
2010-10-14 20:34 ` [RFC][PATCH 4/7] jump_label: More consitent naming Peter Zijlstra
2010-10-18 19:21 ` [tip:perf/core] jump_label: Use more consistent naming tip-bot for Peter Zijlstra
2010-10-14 20:34 ` [RFC][PATCH 5/7] jump_label: atomic_t interface Peter Zijlstra
2010-10-15 14:01 ` Frederic Weisbecker
2010-10-18 19:21 ` [tip:perf/core] jump_label: Add " tip-bot for Peter Zijlstra
2010-10-18 19:21 ` [tip:perf/core] perf: Use jump_labels to optimize the scheduler hooks tip-bot for Peter Zijlstra
2010-10-14 20:34 ` [RFC][PATCH 6/7] perf: use jump_label " Peter Zijlstra
2010-10-15 13:59 ` Frederic Weisbecker
2010-10-17 9:52 ` Peter Zijlstra
2010-10-17 10:16 ` Peter Zijlstra
2010-10-14 20:34 ` [RFC][PATCH 7/7] perf: Optimize sw events Peter Zijlstra
2010-10-15 9:14 ` Peter Zijlstra
2010-10-15 14:18 ` Jason Baron
2010-10-15 14:57 ` Peter Zijlstra
2010-10-15 15:02 ` Jason Baron
2010-10-15 19:32 ` Steven Rostedt
2010-10-15 19:54 ` Peter Zijlstra
2010-10-16 6:27 ` Ingo Molnar
2010-10-15 14:04 ` Frederic Weisbecker
2010-10-15 14:08 ` Peter Zijlstra
2010-10-15 14:11 ` Frederic Weisbecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101014203625.340789919@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=davem@davemloft.net \
--cc=efault@gmx.de \
--cc=fweisbec@gmail.com \
--cc=jbaron@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).