From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnaldo Carvalho de Melo Subject: [PATCH 17/28] perf ftrace: Improve error message about capability to use ftrace Date: Wed, 14 Aug 2019 15:40:40 -0300 Message-ID: <20190814184051.3125-18-acme@kernel.org> References: <20190814184051.3125-1-acme@kernel.org> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20190814184051.3125-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , Alexander Shishkin , Alexey Budankov , Igor Lubashev , James Morris , Mathieu Poirier , Peter Zijlstra , Suzuki Poulouse List-Id: linux-perf-users.vger.kernel.org From: Arnaldo Carvalho de Melo If we link against libcap, then we can state that CAP_SYS_ADMIN is needed, if not, fallback to telling the user it needs to be root, as was before linking against libcap. Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Alexey Budankov Cc: Igor Lubashev Cc: James Morris Cc: Jiri Olsa Cc: Mathieu Poirier Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Suzuki Poulouse Link: https://lkml.kernel.org/n/tip-hhnbjdo8r67054of9zm2kxtl@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-ftrace.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 01a5bb58eb04..1367bb5046a7 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -284,7 +284,13 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) }; if (!perf_cap__capable(CAP_SYS_ADMIN)) { - pr_err("ftrace only works for root!\n"); + pr_err("ftrace only works for %s!\n", +#ifdef HAVE_LIBCAP_SUPPORT + "users with the SYS_ADMIN capability" +#else + "root" +#endif + ); return -1; } -- 2.21.0