aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2011-03-30 03:08:20 -0400
committerIngo Molnar <mingo@elte.hu>2011-03-30 03:08:39 -0400
commit652d78fd7a9ebd881290d6bbbc85925c06b907b4 (patch)
tree5ddef0bcae62e7b95fb8702e4e946d4b5d4e9dc6 /tools
parent9f644c4ba86b76159d36747fda7da496f72a1872 (diff)
parentca6a42586fae639ff9e5285d9bdc550fcb1b8d41 (diff)
Merge commits 'ca6a42586fae' and 'c286c419c784' into perf/urgent
Pick up these two commits from Arnaldo's perf/core tree: ca6a42586fae: perf tools: Emit clearer message for sys_perf_event_open ENOENT return c286c419c784: perf tools: Fixup exit path when not able to open events As they are really fixes we want to have sooner than laer. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-record.c19
-rw-r--r--tools/perf/builtin-top.c44
-rw-r--r--tools/perf/util/debug.c10
-rw-r--r--tools/perf/util/debug.h1
4 files changed, 54 insertions, 20 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 6febcc168a8c..db6adecf46f1 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -275,11 +275,10 @@ try_again:
275 !no_inherit) < 0) { 275 !no_inherit) < 0) {
276 int err = errno; 276 int err = errno;
277 277
278 if (err == EPERM || err == EACCES) 278 if (err == EPERM || err == EACCES) {
279 die("Permission error - are you root?\n" 279 ui__warning_paranoid();
280 "\t Consider tweaking" 280 exit(EXIT_FAILURE);
281 " /proc/sys/kernel/perf_event_paranoid.\n"); 281 } else if (err == ENODEV && cpu_list) {
282 else if (err == ENODEV && cpu_list) {
283 die("No such device - did you specify" 282 die("No such device - did you specify"
284 " an out-of-range profile CPU?\n"); 283 " an out-of-range profile CPU?\n");
285 } else if (err == EINVAL && sample_id_all_avail) { 284 } else if (err == EINVAL && sample_id_all_avail) {
@@ -302,11 +301,19 @@ try_again:
302 && attr->config == PERF_COUNT_HW_CPU_CYCLES) { 301 && attr->config == PERF_COUNT_HW_CPU_CYCLES) {
303 302
304 if (verbose) 303 if (verbose)
305 warning(" ... trying to fall back to cpu-clock-ticks\n"); 304 ui__warning("The cycles event is not supported, "
305 "trying to fall back to cpu-clock-ticks\n");
306 attr->type = PERF_TYPE_SOFTWARE; 306 attr->type = PERF_TYPE_SOFTWARE;
307 attr->config = PERF_COUNT_SW_CPU_CLOCK; 307 attr->config = PERF_COUNT_SW_CPU_CLOCK;
308 goto try_again; 308 goto try_again;
309 } 309 }
310
311 if (err == ENOENT) {
312 ui__warning("The %s event is not supported.\n",
313 event_name(pos));
314 exit(EXIT_FAILURE);
315 }
316
310 printf("\n"); 317 printf("\n");
311 error("sys_perf_event_open() syscall returned with %d (%s). /bin/dmesg may provide additional information.\n", 318 error("sys_perf_event_open() syscall returned with %d (%s). /bin/dmesg may provide additional information.\n",
312 err, strerror(err)); 319 err, strerror(err));
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 676b4fb0070f..fc1273e976c5 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -850,10 +850,10 @@ try_again:
850 top.evlist->threads, group, inherit) < 0) { 850 top.evlist->threads, group, inherit) < 0) {
851 int err = errno; 851 int err = errno;
852 852
853 if (err == EPERM || err == EACCES) 853 if (err == EPERM || err == EACCES) {
854 die("Permission error - are you root?\n" 854 ui__warning_paranoid();
855 "\t Consider tweaking" 855 goto out_err;
856 " /proc/sys/kernel/perf_event_paranoid.\n"); 856 }
857 /* 857 /*
858 * If it's cycles then fall back to hrtimer 858 * If it's cycles then fall back to hrtimer
859 * based cpu-clock-tick sw counter, which 859 * based cpu-clock-tick sw counter, which
@@ -861,25 +861,41 @@ try_again:
861 */ 861 */
862 if (attr->type == PERF_TYPE_HARDWARE && 862 if (attr->type == PERF_TYPE_HARDWARE &&
863 attr->config == PERF_COUNT_HW_CPU_CYCLES) { 863 attr->config == PERF_COUNT_HW_CPU_CYCLES) {
864
865 if (verbose) 864 if (verbose)
866 warning(" ... trying to fall back to cpu-clock-ticks\n"); 865 ui__warning("Cycles event not supported,\n"
866 "trying to fall back to cpu-clock-ticks\n");
867 867
868 attr->type = PERF_TYPE_SOFTWARE; 868 attr->type = PERF_TYPE_SOFTWARE;
869 attr->config = PERF_COUNT_SW_CPU_CLOCK; 869 attr->config = PERF_COUNT_SW_CPU_CLOCK;
870 goto try_again; 870 goto try_again;
871 } 871 }
872 printf("\n"); 872
873 error("sys_perf_event_open() syscall returned with %d " 873 if (err == ENOENT) {
874 "(%s). /bin/dmesg may provide additional information.\n", 874 ui__warning("The %s event is not supported.\n",
875 err, strerror(err)); 875 event_name(counter));
876 die("No CONFIG_PERF_EVENTS=y kernel support configured?\n"); 876 goto out_err;
877 exit(-1); 877 }
878
879 ui__warning("The sys_perf_event_open() syscall "
880 "returned with %d (%s). /bin/dmesg "
881 "may provide additional information.\n"
882 "No CONFIG_PERF_EVENTS=y kernel support "
883 "configured?\n", err, strerror(err));
884 goto out_err;
878 } 885 }
879 } 886 }
880 887
881 if (perf_evlist__mmap(evlist, mmap_pages, false) < 0) 888 if (perf_evlist__mmap(evlist, mmap_pages, false) < 0) {
882 die("failed to mmap with %d (%s)\n", errno, strerror(errno)); 889 ui__warning("Failed to mmap with %d (%s)\n",
890 errno, strerror(errno));
891 goto out_err;
892 }
893
894 return;
895
896out_err:
897 exit_browser(0);
898 exit(0);
883} 899}
884 900
885static int __cmd_top(void) 901static int __cmd_top(void)
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index d4536a9e0d8c..155749d74350 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -57,6 +57,16 @@ void ui__warning(const char *format, ...)
57} 57}
58#endif 58#endif
59 59
60void ui__warning_paranoid(void)
61{
62 ui__warning("Permission error - are you root?\n"
63 "Consider tweaking /proc/sys/kernel/perf_event_paranoid:\n"
64 " -1 - Not paranoid at all\n"
65 " 0 - Disallow raw tracepoint access for unpriv\n"
66 " 1 - Disallow cpu events for unpriv\n"
67 " 2 - Disallow kernel profiling for unpriv\n");
68}
69
60void trace_event(union perf_event *event) 70void trace_event(union perf_event *event)
61{ 71{
62 unsigned char *raw_event = (void *)event; 72 unsigned char *raw_event = (void *)event;
diff --git a/tools/perf/util/debug.h b/tools/perf/util/debug.h
index 93516cf4682c..fd53db47e3de 100644
--- a/tools/perf/util/debug.h
+++ b/tools/perf/util/debug.h
@@ -36,5 +36,6 @@ int ui_helpline__show_help(const char *format, va_list ap);
36#endif 36#endif
37 37
38void ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2))); 38void ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));
39void ui__warning_paranoid(void);
39 40
40#endif /* __PERF_DEBUG_H */ 41#endif /* __PERF_DEBUG_H */