From: Igor Lubashev Date: Wed, 7 Aug 2019 14:44:17 +0000 (-0400) Subject: perf ftrace: Use CAP_SYS_ADMIN instead of euid==0 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=c766f3df635de14295e410c6dd5410bc416c24a0;p=openwrt%2Fstaging%2Fblogic.git perf ftrace: Use CAP_SYS_ADMIN instead of euid==0 The kernel requires CAP_SYS_ADMIN instead of euid==0 to mount debugfs for ftrace. Make perf do the same. Signed-off-by: Igor Lubashev Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Alexey Budankov Cc: James Morris Cc: Mathieu Poirier Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Suzuki Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/bd8763b72ed4d58d0b42d44fbc7eb474d32e53a3.1565188228.git.ilubashe@akamai.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 20d4c0ce8b53..01a5bb58eb04 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "debug.h" #include @@ -21,6 +22,7 @@ #include "target.h" #include "cpumap.h" #include "thread_map.h" +#include "util/cap.h" #include "util/config.h" @@ -281,7 +283,7 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) .events = POLLIN, }; - if (geteuid() != 0) { + if (!perf_cap__capable(CAP_SYS_ADMIN)) { pr_err("ftrace only works for root!\n"); return -1; }