Commit f4c4176f authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

perf events: Allow per-task-per-cpu counters

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: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: fweisbec@gmail.com
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <20091216165904.831451147@chello.nl>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 9b33827d
...@@ -782,6 +782,9 @@ static void __perf_install_in_context(void *info) ...@@ -782,6 +782,9 @@ static void __perf_install_in_context(void *info)
add_event_to_ctx(event, ctx); 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 * Don't put the event on if it is disabled or if
* it is in a group and the group isn't on. * it is in a group and the group isn't on.
...@@ -925,6 +928,9 @@ static void __perf_event_enable(void *info) ...@@ -925,6 +928,9 @@ static void __perf_event_enable(void *info)
goto unlock; goto unlock;
__perf_event_mark_enabled(event, ctx); __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, * If the event is in a group and isn't the group leader,
* then don't put it on unless the group is on. * then don't put it on unless the group is on.
...@@ -1595,10 +1601,7 @@ static struct perf_event_context *find_get_context(pid_t pid, int cpu) ...@@ -1595,10 +1601,7 @@ static struct perf_event_context *find_get_context(pid_t pid, int cpu)
unsigned long flags; unsigned long flags;
int err; int err;
/* if (pid == -1 && cpu != -1) {
* If cpu is not a wildcard then this is a percpu event:
*/
if (cpu != -1) {
/* Must be root to operate on a CPU event: */ /* Must be root to operate on a CPU event: */
if (perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN)) if (perf_paranoid_cpu() && !capable(CAP_SYS_ADMIN))
return ERR_PTR(-EACCES); return ERR_PTR(-EACCES);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment