* [PATCH] perf tools: Fix permission checks
@ 2009-11-08 16:01 Pekka Enberg
2009-11-08 16:09 ` [tip:perf/urgent] " tip-bot for Pekka Enberg
0 siblings, 1 reply; 2+ messages in thread
From: Pekka Enberg @ 2009-11-08 16:01 UTC (permalink / raw)
To: mingo
Cc: linux-kernel, Pekka Enberg, Peter Zijlstra, Paul Mackerras,
Frederic Weisbecker
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?
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
tools/perf/builtin-record.c | 2 +-
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 3eeef33..a4be453 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -426,7 +426,7 @@ try_again:
if (fd[nr_cpu][counter] < 0) {
int err = errno;
- if (err == EPERM)
+ if (err == EPERM || err == EACCES)
die("Permission error - are you root?\n");
else if (err == ENODEV && profile_cpu != -1)
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 a1b1d10..e23bc74 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1027,7 +1027,7 @@ try_again:
if (fd[i][counter] < 0) {
int err = errno;
- if (err == EPERM)
+ if (err == EPERM || err == EACCES)
die("No permission - are you root?\n");
/*
* If it's cycles then fall back to hrtimer
--
1.6.3.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [tip:perf/urgent] perf tools: Fix permission checks
2009-11-08 16:01 [PATCH] perf tools: Fix permission checks Pekka Enberg
@ 2009-11-08 16:09 ` tip-bot for Pekka Enberg
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Pekka Enberg @ 2009-11-08 16:09 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, paulus, hpa, mingo, a.p.zijlstra, penberg, fweisbec,
tglx, mingo
Commit-ID: c10edee2e1716f8cf217cf52ed01ae4742fcdf3c
Gitweb: http://git.kernel.org/tip/c10edee2e1716f8cf217cf52ed01ae4742fcdf3c
Author: Pekka Enberg <penberg@cs.helsinki.fi>
AuthorDate: Sun, 8 Nov 2009 18:01:06 +0200
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Sun, 8 Nov 2009 17:04:54 +0100
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>
---
tools/perf/builtin-record.c | 2 +-
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 3eeef33..a4be453 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -426,7 +426,7 @@ try_again:
if (fd[nr_cpu][counter] < 0) {
int err = errno;
- if (err == EPERM)
+ if (err == EPERM || err == EACCES)
die("Permission error - are you root?\n");
else if (err == ENODEV && profile_cpu != -1)
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 a1b1d10..e23bc74 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1027,7 +1027,7 @@ try_again:
if (fd[i][counter] < 0) {
int err = errno;
- if (err == EPERM)
+ if (err == EPERM || err == EACCES)
die("No permission - are you root?\n");
/*
* If it's cycles then fall back to hrtimer
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-08 16:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-08 16:01 [PATCH] perf tools: Fix permission checks Pekka Enberg
2009-11-08 16:09 ` [tip:perf/urgent] " tip-bot for Pekka Enberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox