[PATCH 12/43] perf utils: Silence "Couldn't synthesize bpf events" warning for EPERM

From: Arnaldo Carvalho de Melo
Date: Thu Feb 14 2019 - 19:50:04 EST


From: Song Liu <songliubraving@xxxxxx>

Synthesizing BPF events is only supported for root. Silent warning msg
when non-root user runs perf-record.

Reported-by: David Carrillo-Cisneros <davidca@xxxxxx>
Signed-off-by: Song Liu <songliubraving@xxxxxx>
Tested-by: David Carrillo-Cisneros <davidca@xxxxxx>
Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: kernel-team@xxxxxx
Link: http://lkml.kernel.org/r/20190204193140.719740-1-songliubraving@xxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/util/bpf-event.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/bpf-event.c b/tools/perf/util/bpf-event.c
index 796ef793f4ce..62dda96b0096 100644
--- a/tools/perf/util/bpf-event.c
+++ b/tools/perf/util/bpf-event.c
@@ -236,8 +236,8 @@ int perf_event__synthesize_bpf_events(struct perf_tool *tool,
pr_debug("%s: can't get next program: %s%s",
__func__, strerror(errno),
errno == EINVAL ? " -- kernel too old?" : "");
- /* don't report error on old kernel */
- err = (errno == EINVAL) ? 0 : -1;
+ /* don't report error on old kernel or EPERM */
+ err = (errno == EINVAL || errno == EPERM) ? 0 : -1;
break;
}
fd = bpf_prog_get_fd_by_id(id);
--
2.19.1