Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754459AbZKHQIM (ORCPT ); Sun, 8 Nov 2009 11:08:12 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753882AbZKHQIL (ORCPT ); Sun, 8 Nov 2009 11:08:11 -0500 Received: from smtp5.welho.com ([213.243.153.39]:44746 "EHLO smtp5.welho.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753206AbZKHQIL (ORCPT ); Sun, 8 Nov 2009 11:08:11 -0500 X-Greylist: delayed 419 seconds by postgrey-1.27 at vger.kernel.org; Sun, 08 Nov 2009 11:08:10 EST From: Pekka Enberg To: mingo@elte.hu Cc: linux-kernel@vger.kernel.org, Pekka Enberg , Peter Zijlstra , Paul Mackerras , Frederic Weisbecker Subject: [PATCH] perf tools: Fix permission checks Date: Sun, 8 Nov 2009 18:01:06 +0200 Message-Id: <1257696066-4046-1-git-send-email-penberg@cs.helsinki.fi> X-Mailer: git-send-email 1.6.3.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1921 Lines: 58 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 Cc: Paul Mackerras Cc: Frederic Weisbecker Signed-off-by: Pekka Enberg --- 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/