aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/evsel.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-02-21 14:05:50 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-02-21 20:27:59 -0500
commite603dc15072c7fec0ae263597e6dabc3bb4c5c5b (patch)
treea4fa6e1a548570ce71b8ed97399933de7303c321 /tools/perf/util/evsel.c
parentfbee632d0ca9f4073a3fefb9a843eac8af036b0f (diff)
perf evsel: Fix inverted test for fixing up attr.inherit flag
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>
Diffstat (limited to 'tools/perf/util/evsel.c')
-rw-r--r--tools/perf/util/evsel.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 63cadaf3e208..8083d5126fca 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -179,8 +179,19 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
179 179
180 for (cpu = 0; cpu < cpus->nr; cpu++) { 180 for (cpu = 0; cpu < cpus->nr; cpu++) {
181 int group_fd = -1; 181 int group_fd = -1;
182 182 /*
183 evsel->attr.inherit = (cpus->map[cpu] < 0) && inherit; 183 * Don't allow mmap() of inherited per-task counters. This
184 * would create a performance issue due to all children writing
185 * to the same buffer.
186 *
187 * FIXME:
188 * Proper fix is not to pass 'inherit' to perf_evsel__open*,
189 * but a 'flags' parameter, with 'group' folded there as well,
190 * then introduce a PERF_O_{MMAP,GROUP,INHERIT} enum, and if
191 * O_MMAP is set, emit a warning if cpu < 0 and O_INHERIT is
192 * set. Lets go for the minimal fix first tho.
193 */
194 evsel->attr.inherit = (cpus->map[cpu] >= 0) && inherit;
184 195
185 for (thread = 0; thread < threads->nr; thread++) { 196 for (thread = 0; thread < threads->nr; thread++) {
186 197