Welcome to Soft32 Linux Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

[PATCH] perf tools: Fix permission checks

 
   Soft32 Home -> Linux -> Kernel RSS
Next:  [PATCH] extend print_fatal_signals for reached RL..  
Author Message
Pekka Enberg

External


Since: Feb 21, 2007
Posts: 154



(Msg. 1) Posted: Sun Nov 08, 2009 1:20 pm
Post subject: [PATCH] perf tools: Fix permission checks
Archived from groups: linux>kernel (more info?)

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.RemoveThis@chello.nl>
Cc: Paul Mackerras <paulus.RemoveThis@samba.org>
Cc: Frederic Weisbecker <fweisbec.RemoveThis@gmail.com>
Signed-off-by: Pekka Enberg <penberg.RemoveThis@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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.RemoveThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
tip-bot for Pekka Enberg

External


Since: May 28, 2009
Posts: 4



(Msg. 2) Posted: Sun Nov 08, 2009 3:20 pm
Post subject: [tip:perf/urgent] perf tools: Fix permission checks [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Commit-ID: c10edee2e1716f8cf217cf52ed01ae4742fcdf3c
Gitweb: http://git.kernel.org/tip/c10edee2e1716f8cf217cf52ed01ae4742fcdf3c
Author: Pekka Enberg <penberg DeleteThis @cs.helsinki.fi>
AuthorDate: Sun, 8 Nov 2009 18:01:06 +0200
Committer: Ingo Molnar <mingo DeleteThis @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 DeleteThis @cs.helsinki.fi>
Cc: Peter Zijlstra <a.p.zijlstra DeleteThis @chello.nl>
Cc: Paul Mackerras <paulus DeleteThis @samba.org>
Cc: Frederic Weisbecker <fweisbec DeleteThis @gmail.com>
LKML-Reference: <1257696066-4046-1-git-send-email-penberg DeleteThis @cs.helsinki.fi>
Signed-off-by: Ingo Molnar <mingo DeleteThis @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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo DeleteThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Display posts from previous:   
Related Topics:
[patch] i386: more ioapic checks - Coverity reports apic numbers are being passed to functions without checking to see if they are legal. (This is Kernel...

[PATCH] more sanity checks in Dwarf2 unwinder - Tighten the requirements on both input to and output from the Dwarf2 unwinder. Signed-off-by: Jan Beulich..

[PATCH 4/5] sata_nv: Use notifier for completion checks - The hardware provides us a notifier register that indicates what command tags have completed. Use this to determine..

[RFC: 2.6 patch] bcm43xx_sprom_write(): add error checks - The Coverity checker noted that these "if (err)"'s couldn't ever be true. It seems the intention was to che...

[PATCH] Remove redundant #ifdef __KERNEL__ checks. - Remove the redundant intermediate checks for __KERNEL__ since, as soon as one ends, the next one starts. Signed-off-by...

[PATCH] dtlk: fix error checks in module_init() - This patch fixes two things in module_init. - fix register_chrdev() error check Currently dtlk doesn't check..
       Soft32 Home -> Linux -> Kernel All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Categories:
 Windows
  Linux
 Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]