diff options
author | Jiri Olsa <jolsa@kernel.org> | 2018-04-23 05:08:17 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-04-23 10:14:10 -0400 |
commit | 129193bb0c43d42f1c397c175346e3e0dba5a578 (patch) | |
tree | 40bd599fb1569f1ea911d065346d8239e1ed081a /tools/perf | |
parent | b31a8cc1a53dda3a33b6c9c62779869d4d5fc142 (diff) |
perf stat: Keep the / modifier separator in fallback
The 'perf stat' fallback for EACCES error sets the exclude_kernel
perf_event_attr and tries perf_event_open() again with it. In addition,
it also changes the name of the event to reflect that change by adding
the 'u' modifier.
But it does not take into account the '/' separator, so the event name
can end up mangled, like: (note the '/:' characters)
$ perf stat -e cpu/cpu-cycles/ kill
...
386,832 cpu/cpu-cycles/:u
Adding the code to check on the '/' separator and set the following
correct event name:
$ perf stat -e cpu/cpu-cycles/ kill
...
388,548 cpu/cpu-cycles/u
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20180423090823.32309-4-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/evsel.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 3e87486c28fe..7eb1e9850abf 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -2754,8 +2754,14 @@ bool perf_evsel__fallback(struct perf_evsel *evsel, int err, | |||
2754 | (paranoid = perf_event_paranoid()) > 1) { | 2754 | (paranoid = perf_event_paranoid()) > 1) { |
2755 | const char *name = perf_evsel__name(evsel); | 2755 | const char *name = perf_evsel__name(evsel); |
2756 | char *new_name; | 2756 | char *new_name; |
2757 | const char *sep = ":"; | ||
2757 | 2758 | ||
2758 | if (asprintf(&new_name, "%s%su", name, strchr(name, ':') ? "" : ":") < 0) | 2759 | /* Is there already the separator in the name. */ |
2760 | if (strchr(name, '/') || | ||
2761 | strchr(name, ':')) | ||
2762 | sep = ""; | ||
2763 | |||
2764 | if (asprintf(&new_name, "%s%su", name, sep) < 0) | ||
2759 | return false; | 2765 | return false; |
2760 | 2766 | ||
2761 | if (evsel->name) | 2767 | if (evsel->name) |