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-top.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-top.c')
-rw-r--r-- | tools/perf/builtin-top.c | 34 |
1 files changed, 5 insertions, 29 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 8d41d0b58956..f5fd260f7b20 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -892,7 +892,7 @@ static void perf_top__mmap_read(struct perf_top *top) | |||
892 | 892 | ||
893 | static void perf_top__start_counters(struct perf_top *top) | 893 | static void perf_top__start_counters(struct perf_top *top) |
894 | { | 894 | { |
895 | char msg[128]; | 895 | char msg[512]; |
896 | struct perf_evsel *counter; | 896 | struct perf_evsel *counter; |
897 | struct perf_evlist *evlist = top->evlist; | 897 | struct perf_evlist *evlist = top->evlist; |
898 | struct perf_record_opts *opts = &top->record_opts; | 898 | struct perf_record_opts *opts = &top->record_opts; |
@@ -900,42 +900,18 @@ static void perf_top__start_counters(struct perf_top *top) | |||
900 | perf_evlist__config(evlist, opts); | 900 | perf_evlist__config(evlist, opts); |
901 | 901 | ||
902 | list_for_each_entry(counter, &evlist->entries, node) { | 902 | list_for_each_entry(counter, &evlist->entries, node) { |
903 | struct perf_event_attr *attr = &counter->attr; | ||
904 | try_again: | 903 | try_again: |
905 | if (perf_evsel__open(counter, top->evlist->cpus, | 904 | if (perf_evsel__open(counter, top->evlist->cpus, |
906 | top->evlist->threads) < 0) { | 905 | top->evlist->threads) < 0) { |
907 | int err = errno; | 906 | if (perf_evsel__fallback(counter, errno, msg, sizeof(msg))) { |
908 | |||
909 | if (err == EPERM || err == EACCES) { | ||
910 | ui__error_paranoid(); | ||
911 | goto out_err; | ||
912 | } | ||
913 | |||
914 | if (perf_evsel__fallback(counter, err, msg, sizeof(msg))) { | ||
915 | if (verbose) | 907 | if (verbose) |
916 | ui__warning("%s\n", msg); | 908 | ui__warning("%s\n", msg); |
917 | goto try_again; | 909 | goto try_again; |
918 | } | 910 | } |
919 | 911 | ||
920 | if (err == ENOENT) { | 912 | perf_evsel__open_strerror(counter, &opts->target, |
921 | ui__error("The %s event is not supported.\n", | 913 | errno, msg, sizeof(msg)); |
922 | perf_evsel__name(counter)); | 914 | ui__error("%s\n", msg); |
923 | goto out_err; | ||
924 | } else if (err == EMFILE) { | ||
925 | ui__error("Too many events are opened.\n" | ||
926 | "Try again after reducing the number of events\n"); | ||
927 | goto out_err; | ||
928 | } else if ((err == EOPNOTSUPP) && (attr->precise_ip)) { | ||
929 | ui__error("\'precise\' request may not be supported. " | ||
930 | "Try removing 'p' modifier\n"); | ||
931 | goto out_err; | ||
932 | } | ||
933 | |||
934 | ui__error("The sys_perf_event_open() syscall " | ||
935 | "returned with %d (%s). /bin/dmesg " | ||
936 | "may provide additional information.\n" | ||
937 | "No CONFIG_PERF_EVENTS=y kernel support " | ||
938 | "configured?\n", err, strerror(err)); | ||
939 | goto out_err; | 915 | goto out_err; |
940 | } | 916 | } |
941 | } | 917 | } |