diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-12-13 12:16:30 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-01-24 14:40:08 -0500 |
commit | c0a54341c0e89333ef201fc3f3001176962f6121 (patch) | |
tree | d43d2fcb1c49ae17cbf8cf9aa270694b88cf39e1 /tools/perf/util/evsel.c | |
parent | 594ac61ad3be9c80c738a9fe3bb95c05d8d1bae1 (diff) |
perf evsel: Introduce event fallback method
The only fallback right now is for HW cpu-cycles -> SW cpu-clock, that
was done in the same way in both 'top' and 'record'.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-58l1mgibh9oa9m0pd3fasxa5@git.kernel.org
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.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index ee6ee3f45c2a..0c88e5c12dab 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -1378,3 +1378,31 @@ int perf_evsel__fprintf(struct perf_evsel *evsel, | |||
1378 | fputc('\n', fp); | 1378 | fputc('\n', fp); |
1379 | return ++printed; | 1379 | return ++printed; |
1380 | } | 1380 | } |
1381 | |||
1382 | bool perf_evsel__fallback(struct perf_evsel *evsel, int err, | ||
1383 | char *msg, size_t msgsize) | ||
1384 | { | ||
1385 | if ((err == ENOENT || err == ENXIO) && | ||
1386 | evsel->attr.type == PERF_TYPE_HARDWARE && | ||
1387 | evsel->attr.config == PERF_COUNT_HW_CPU_CYCLES) { | ||
1388 | /* | ||
1389 | * If it's cycles then fall back to hrtimer based | ||
1390 | * cpu-clock-tick sw counter, which is always available even if | ||
1391 | * no PMU support. | ||
1392 | * | ||
1393 | * PPC returns ENXIO until 2.6.37 (behavior changed with commit | ||
1394 | * b0a873e). | ||
1395 | */ | ||
1396 | scnprintf(msg, msgsize, "%s", | ||
1397 | "The cycles event is not supported, trying to fall back to cpu-clock-ticks"); | ||
1398 | |||
1399 | evsel->attr.type = PERF_TYPE_SOFTWARE; | ||
1400 | evsel->attr.config = PERF_COUNT_SW_CPU_CLOCK; | ||
1401 | |||
1402 | free(evsel->name); | ||
1403 | evsel->name = NULL; | ||
1404 | return true; | ||
1405 | } | ||
1406 | |||
1407 | return false; | ||
1408 | } | ||