aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r--tools/perf/builtin-top.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 70f1075cc5b0..7e3d6e310bf8 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -515,7 +515,9 @@ static void handle_keypress(struct perf_session *session, int c)
515 break; 515 break;
516 case 'E': 516 case 'E':
517 if (top.evlist->nr_entries > 1) { 517 if (top.evlist->nr_entries > 1) {
518 int counter; 518 /* Select 0 as the default event: */
519 int counter = 0;
520
519 fprintf(stderr, "\nAvailable events:"); 521 fprintf(stderr, "\nAvailable events:");
520 522
521 list_for_each_entry(top.sym_evsel, &top.evlist->entries, node) 523 list_for_each_entry(top.sym_evsel, &top.evlist->entries, node)
@@ -843,15 +845,16 @@ static void start_counters(struct perf_evlist *evlist)
843 } 845 }
844 846
845 attr->mmap = 1; 847 attr->mmap = 1;
848 attr->inherit = inherit;
846try_again: 849try_again:
847 if (perf_evsel__open(counter, top.evlist->cpus, 850 if (perf_evsel__open(counter, top.evlist->cpus,
848 top.evlist->threads, group, inherit) < 0) { 851 top.evlist->threads, group) < 0) {
849 int err = errno; 852 int err = errno;
850 853
851 if (err == EPERM || err == EACCES) 854 if (err == EPERM || err == EACCES) {
852 die("Permission error - are you root?\n" 855 ui__warning_paranoid();
853 "\t Consider tweaking" 856 goto out_err;
854 " /proc/sys/kernel/perf_event_paranoid.\n"); 857 }
855 /* 858 /*
856 * If it's cycles then fall back to hrtimer 859 * If it's cycles then fall back to hrtimer
857 * based cpu-clock-tick sw counter, which 860 * based cpu-clock-tick sw counter, which
@@ -859,25 +862,41 @@ try_again:
859 */ 862 */
860 if (attr->type == PERF_TYPE_HARDWARE && 863 if (attr->type == PERF_TYPE_HARDWARE &&
861 attr->config == PERF_COUNT_HW_CPU_CYCLES) { 864 attr->config == PERF_COUNT_HW_CPU_CYCLES) {
862
863 if (verbose) 865 if (verbose)
864 warning(" ... trying to fall back to cpu-clock-ticks\n"); 866 ui__warning("Cycles event not supported,\n"
867 "trying to fall back to cpu-clock-ticks\n");
865 868
866 attr->type = PERF_TYPE_SOFTWARE; 869 attr->type = PERF_TYPE_SOFTWARE;
867 attr->config = PERF_COUNT_SW_CPU_CLOCK; 870 attr->config = PERF_COUNT_SW_CPU_CLOCK;
868 goto try_again; 871 goto try_again;
869 } 872 }
870 printf("\n"); 873
871 error("sys_perf_event_open() syscall returned with %d " 874 if (err == ENOENT) {
872 "(%s). /bin/dmesg may provide additional information.\n", 875 ui__warning("The %s event is not supported.\n",
873 err, strerror(err)); 876 event_name(counter));
874 die("No CONFIG_PERF_EVENTS=y kernel support configured?\n"); 877 goto out_err;
875 exit(-1); 878 }
879
880 ui__warning("The sys_perf_event_open() syscall "
881 "returned with %d (%s). /bin/dmesg "
882 "may provide additional information.\n"
883 "No CONFIG_PERF_EVENTS=y kernel support "
884 "configured?\n", err, strerror(err));
885 goto out_err;
876 } 886 }
877 } 887 }
878 888
879 if (perf_evlist__mmap(evlist, mmap_pages, false) < 0) 889 if (perf_evlist__mmap(evlist, mmap_pages, false) < 0) {
880 die("failed to mmap with %d (%s)\n", errno, strerror(errno)); 890 ui__warning("Failed to mmap with %d (%s)\n",
891 errno, strerror(errno));
892 goto out_err;
893 }
894
895 return;
896
897out_err:
898 exit_browser(0);
899 exit(0);
881} 900}
882 901
883static int __cmd_top(void) 902static int __cmd_top(void)