aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
authorCorey Ashford <cjashfor@linux.vnet.ibm.com>2010-11-19 20:37:24 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-11-20 10:04:15 -0500
commitd9cf837ef9629ab34167bd6fc0141383ddb8813a (patch)
tree3da536a15ea586dacb113f50f76e566a96216908 /tools/perf/builtin-top.c
parent4aafd3f71a257a3522932944b5204262dfdff147 (diff)
perf stat: Change and clean up sys_perf_event_open error handling
This patch makes several changes to "perf stat": - "perf stat" will no longer go ahead and run the application when one or more of the specified events could not be opened. - Use error() and die() instead of pr_err() so that the output is more consistent with "perf top" and "perf record". - Handle permission errors in a more robust way, and in a similar way to "perf record" and "perf top". In addition, the sys_perf_event_open() error handling of "perf top" and "perf record" is made more consistent and adds the following phrase when an event doesn't open (with something ther than an access or permission error): "/bin/dmesg may provide additional information." This is added because kernel code doesn't have a good way of expressing detailed errors to user space, so its only avenue is to use printk's. However, many users may not think of looking at dmesg to find out why an event is being rejected. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <fweisbec@gmail.com> Cc: Ian Munsie <ianmunsi@au1.ibm.com> Cc: Michael Ellerman <michaele@au1.ibm.com> LKML-Reference: <1290217044-26293-1-git-send-email-cjashfor@linux.vnet.ibm.com> Signed-off-by: Corey Ashford <cjashfor@linux.vnet.ibm.com> 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.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index dd625808c2a5..3d2b47d5121a 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1214,7 +1214,9 @@ try_again:
1214 int err = errno; 1214 int err = errno;
1215 1215
1216 if (err == EPERM || err == EACCES) 1216 if (err == EPERM || err == EACCES)
1217 die("No permission - are you root?\n"); 1217 die("Permission error - are you root?\n"
1218 "\t Consider tweaking"
1219 " /proc/sys/kernel/perf_event_paranoid.\n");
1218 /* 1220 /*
1219 * If it's cycles then fall back to hrtimer 1221 * If it's cycles then fall back to hrtimer
1220 * based cpu-clock-tick sw counter, which 1222 * based cpu-clock-tick sw counter, which
@@ -1231,7 +1233,7 @@ try_again:
1231 goto try_again; 1233 goto try_again;
1232 } 1234 }
1233 printf("\n"); 1235 printf("\n");
1234 error("perfcounter syscall returned with %d (%s)\n", 1236 error("sys_perf_event_open() syscall returned with %d (%s). /bin/dmesg may provide additional information.\n",
1235 fd[i][counter][thread_index], strerror(err)); 1237 fd[i][counter][thread_index], strerror(err));
1236 die("No CONFIG_PERF_EVENTS=y kernel support configured?\n"); 1238 die("No CONFIG_PERF_EVENTS=y kernel support configured?\n");
1237 exit(-1); 1239 exit(-1);