diff options
author | Pekka Enberg <penberg@cs.helsinki.fi> | 2009-11-08 11:01:06 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-08 11:04:54 -0500 |
commit | c10edee2e1716f8cf217cf52ed01ae4742fcdf3c (patch) | |
tree | 30d894124621ba13ea5e7e06050b99953a401b62 /tools/perf | |
parent | dd77038d233d106f297b907bf51459dfb1099eb1 (diff) |
perf tools: Fix permission checks
The perf_event_open() system call returns EACCES if the user is
not root which results in a very confusing error message:
$ perf record -A -a -f
Error: perfcounter syscall returned with -1 (Permission denied)
Fatal: No CONFIG_PERF_EVENTS=y kernel support configured?
It turns out that's because perf tools are checking only for
EPERM. Fix that up to get a much better error message:
$ perf record -A -a -f
Fatal: Permission error - are you root?
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <1257696066-4046-1-git-send-email-penberg@cs.helsinki.fi>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-record.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 3eeef339c787..a4be453fc8a9 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -426,7 +426,7 @@ try_again: | |||
426 | if (fd[nr_cpu][counter] < 0) { | 426 | if (fd[nr_cpu][counter] < 0) { |
427 | int err = errno; | 427 | int err = errno; |
428 | 428 | ||
429 | if (err == EPERM) | 429 | if (err == EPERM || err == EACCES) |
430 | die("Permission error - are you root?\n"); | 430 | die("Permission error - are you root?\n"); |
431 | else if (err == ENODEV && profile_cpu != -1) | 431 | else if (err == ENODEV && profile_cpu != -1) |
432 | die("No such device - did you specify an out-of-range profile CPU?\n"); | 432 | die("No such device - did you specify an out-of-range profile CPU?\n"); |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index a1b1d10912dc..e23bc74e734f 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -1027,7 +1027,7 @@ try_again: | |||
1027 | if (fd[i][counter] < 0) { | 1027 | if (fd[i][counter] < 0) { |
1028 | int err = errno; | 1028 | int err = errno; |
1029 | 1029 | ||
1030 | if (err == EPERM) | 1030 | if (err == EPERM || err == EACCES) |
1031 | die("No permission - are you root?\n"); | 1031 | die("No permission - are you root?\n"); |
1032 | /* | 1032 | /* |
1033 | * If it's cycles then fall back to hrtimer | 1033 | * If it's cycles then fall back to hrtimer |