diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-12-13 13:10:58 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-01-24 14:40:09 -0500 |
commit | 56e52e85366717481cde16b3480f015c7eb32ba3 (patch) | |
tree | 5e68bd51510915b6da7db8e0fdcc5fc766dd6b6a /tools/perf/util/evsel.c | |
parent | c0a54341c0e89333ef201fc3f3001176962f6121 (diff) |
perf evsel: Introduce perf_evsel__open_strerror method
That consolidates the error messages in 'record', 'stat' and 'top', that
now get a consistent set of messages and allow other tools to use the
new method to report problems using whatever UI toolkit.
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-1cudb7wl996kz7ilz83ctvhr@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 | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 0c88e5c12dab..e45332d08a58 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -1406,3 +1406,52 @@ bool perf_evsel__fallback(struct perf_evsel *evsel, int err, | |||
1406 | 1406 | ||
1407 | return false; | 1407 | return false; |
1408 | } | 1408 | } |
1409 | |||
1410 | int perf_evsel__open_strerror(struct perf_evsel *evsel, | ||
1411 | struct perf_target *target, | ||
1412 | int err, char *msg, size_t size) | ||
1413 | { | ||
1414 | switch (err) { | ||
1415 | case EPERM: | ||
1416 | case EACCES: | ||
1417 | return scnprintf(msg, size, "%s", | ||
1418 | "You may not have permission to collect %sstats.\n" | ||
1419 | "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n" | ||
1420 | " -1 - Not paranoid at all\n" | ||
1421 | " 0 - Disallow raw tracepoint access for unpriv\n" | ||
1422 | " 1 - Disallow cpu events for unpriv\n" | ||
1423 | " 2 - Disallow kernel profiling for unpriv", | ||
1424 | target->system_wide ? "system-wide " : ""); | ||
1425 | case ENOENT: | ||
1426 | return scnprintf(msg, size, "The %s event is not supported.", | ||
1427 | perf_evsel__name(evsel)); | ||
1428 | case EMFILE: | ||
1429 | return scnprintf(msg, size, "%s", | ||
1430 | "Too many events are opened.\n" | ||
1431 | "Try again after reducing the number of events."); | ||
1432 | case ENODEV: | ||
1433 | if (target->cpu_list) | ||
1434 | return scnprintf(msg, size, "%s", | ||
1435 | "No such device - did you specify an out-of-range profile CPU?\n"); | ||
1436 | break; | ||
1437 | case EOPNOTSUPP: | ||
1438 | if (evsel->attr.precise_ip) | ||
1439 | return scnprintf(msg, size, "%s", | ||
1440 | "\'precise\' request may not be supported. Try removing 'p' modifier."); | ||
1441 | #if defined(__i386__) || defined(__x86_64__) | ||
1442 | if (evsel->attr.type == PERF_TYPE_HARDWARE) | ||
1443 | return scnprintf(msg, size, "%s", | ||
1444 | "No hardware sampling interrupt available.\n" | ||
1445 | "No APIC? If so then you can boot the kernel with the \"lapic\" boot parameter to force-enable it."); | ||
1446 | #endif | ||
1447 | break; | ||
1448 | default: | ||
1449 | break; | ||
1450 | } | ||
1451 | |||
1452 | return scnprintf(msg, size, | ||
1453 | "The sys_perf_event_open() syscall returned with %d (%s) for event (%s). \n" | ||
1454 | "/bin/dmesg may provide additional information.\n" | ||
1455 | "No CONFIG_PERF_EVENTS=y kernel support configured?\n", | ||
1456 | err, strerror(err), perf_evsel__name(evsel)); | ||
1457 | } | ||