perf evsel: Fix inverted test for fixing up attr.inherit flag
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 21 Feb 2011 19:05:50 +0000 (16:05 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 22 Feb 2011 01:27:59 +0000 (22:27 -0300)
The kernel refuses mmapping an event with the inherit flag set for
something that is systemwide (cpu == -1), and the evsel layer got this
reversed at some point, fix it.

The symtom was that the --pid and --tid parameters for 'perf record' and
'perf top' returned with -EINVAL, like:

 # /tmp/build-perf/perf record -v -fo/tmp/perf.data -p 1042
   Warning:  ... trying to fall back to cpu-clock-ticks

   Fatal: failed to mmap with 22 (Invalid argument)

Reported-by: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/evsel.c

index 63cadaf3e2083f8f131f2cd1343556e578ed8fbc..8083d5126fca7c213f8aae3dfc42961d488de91a 100644 (file)
@@ -179,8 +179,19 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
 
        for (cpu = 0; cpu < cpus->nr; cpu++) {
                int group_fd = -1;
-
-               evsel->attr.inherit = (cpus->map[cpu] < 0) && inherit;
+               /*
+                * Don't allow mmap() of inherited per-task counters. This
+                * would create a performance issue due to all children writing
+                * to the same buffer.
+                *
+                * FIXME:
+                * Proper fix is not to pass 'inherit' to perf_evsel__open*,
+                * but a 'flags' parameter, with 'group' folded there as well,
+                * then introduce a PERF_O_{MMAP,GROUP,INHERIT} enum, and if
+                * O_MMAP is set, emit a warning if cpu < 0 and O_INHERIT is
+                * set. Lets go for the minimal fix first tho.
+                */
+               evsel->attr.inherit = (cpus->map[cpu] >= 0) && inherit;
 
                for (thread = 0; thread < threads->nr; thread++) {
 
This page took 0.026957 seconds and 5 git commands to generate.