From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>,
fweisbec@gmail.com, linux-kernel@vger.kernel.org,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 1/3] perf: Allow per-task-per-cpu counters
Date: Wed, 16 Dec 2009 17:55:54 +0100 [thread overview]
Message-ID: <20091216165904.831451147@chello.nl> (raw)
In-Reply-To: <20091216165553.802559834@chello.nl>
[-- Attachment #1: perf1.patch --]
[-- Type: text/plain, Size: 1755 bytes --]
In order to allow for per-task-per-cpu counters, useful for
scalability when profiling task hierarchies, we allow installing
events with event->cpu != -1 in task contexts.
__perf_event_sched_in() already skips events where ->cpu mis-matches
the current cpu, fix up __perf_install_in_context() and
__perf_event_enable() to also respect this filter.
This does lead to vary hard to interpret enabled/running times for
such counters, but I don't see a simple solution for that.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
kernel/perf_event.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
Index: linux-2.6/kernel/perf_event.c
===================================================================
--- linux-2.6.orig/kernel/perf_event.c
+++ linux-2.6/kernel/perf_event.c
@@ -782,6 +782,9 @@ static void __perf_install_in_context(vo
add_event_to_ctx(event, ctx);
+ if (event->cpu != -1 && event->cpu != smp_processor_id())
+ goto unlock;
+
/*
* Don't put the event on if it is disabled or if
* it is in a group and the group isn't on.
@@ -925,6 +928,9 @@ static void __perf_event_enable(void *in
goto unlock;
__perf_event_mark_enabled(event, ctx);
+ if (event->cpu != -1 && event->cpu != smp_processor_id())
+ goto unlock;
+
/*
* If the event is in a group and isn't the group leader,
* then don't put it on unless the group is on.
@@ -1595,10 +1601,7 @@ static struct perf_event_context *find_g
unsigned long flags;
int err;
- /*
- * If cpu is not a wildcard then this is a percpu event:
- */
- if (cpu != -1) {
+ if (pid == -1 && cpu != -1) {
/* Must be root to operate on a CPU event: */
if (perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN))
return ERR_PTR(-EACCES);
--
next prev parent reply other threads:[~2009-12-16 17:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-16 16:55 [PATCH 0/3] perf per-task-per-cpu support Peter Zijlstra
2009-12-16 16:55 ` Peter Zijlstra [this message]
2009-12-16 17:34 ` [tip:perf/urgent] perf events: Allow per-task-per-cpu counters tip-bot for Peter Zijlstra
2009-12-16 16:55 ` [PATCH 2/3] perf-record: Properly synchronize child creation Peter Zijlstra
2009-12-16 17:34 ` [tip:perf/urgent] perf record: " tip-bot for Peter Zijlstra
2009-12-16 16:55 ` [PATCH 3/3] perf-record: Use per-task-per-cpu events for inherited events Peter Zijlstra
2009-12-16 17:34 ` [tip:perf/urgent] perf record: " tip-bot for Peter Zijlstra
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=20091216165904.831451147@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
/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
all inboxes | Powered by JetHome®