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/builtin-stat.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/builtin-stat.c')
-rw-r--r-- | tools/perf/builtin-stat.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index ef067c193f93..1c2ac148a7d5 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -247,6 +247,7 @@ static int read_counter(struct perf_evsel *counter) | |||
247 | 247 | ||
248 | static int __run_perf_stat(int argc __maybe_unused, const char **argv) | 248 | static int __run_perf_stat(int argc __maybe_unused, const char **argv) |
249 | { | 249 | { |
250 | char msg[512]; | ||
250 | unsigned long long t0, t1; | 251 | unsigned long long t0, t1; |
251 | struct perf_evsel *counter; | 252 | struct perf_evsel *counter; |
252 | int status = 0; | 253 | int status = 0; |
@@ -324,20 +325,13 @@ static int __run_perf_stat(int argc __maybe_unused, const char **argv) | |||
324 | continue; | 325 | continue; |
325 | } | 326 | } |
326 | 327 | ||
327 | if (errno == EPERM || errno == EACCES) { | 328 | perf_evsel__open_strerror(counter, &target, |
328 | error("You may not have permission to collect %sstats.\n" | 329 | errno, msg, sizeof(msg)); |
329 | "\t Consider tweaking" | 330 | ui__error("%s\n", msg); |
330 | " /proc/sys/kernel/perf_event_paranoid or running as root.", | 331 | |
331 | target.system_wide ? "system-wide " : ""); | ||
332 | } else { | ||
333 | error("open_counter returned with %d (%s). " | ||
334 | "/bin/dmesg may provide additional information.\n", | ||
335 | errno, strerror(errno)); | ||
336 | } | ||
337 | if (child_pid != -1) | 332 | if (child_pid != -1) |
338 | kill(child_pid, SIGTERM); | 333 | kill(child_pid, SIGTERM); |
339 | 334 | ||
340 | pr_err("Not all events could be opened.\n"); | ||
341 | return -1; | 335 | return -1; |
342 | } | 336 | } |
343 | counter->supported = true; | 337 | counter->supported = true; |