Skip to content

Commit

Permalink
perf tools: Fix permission checks
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Pekka Enberg authored and Ingo Molnar committed Nov 8, 2009
1 parent dd77038 commit c10edee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ static void create_counter(int counter, int cpu, pid_t pid)
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");
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-top.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ static void start_counter(int i, int counter)
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
Expand Down

0 comments on commit c10edee

Please sign in to comment.