[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230318002218.2035109-1-namhyung@kernel.org>
Date: Fri, 17 Mar 2023 17:22:18 -0700
From: Namhyung Kim <namhyung@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>
Cc: Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
LKML <linux-kernel@...r.kernel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
linux-perf-users@...r.kernel.org
Subject: [PATCH] perf bpf filter: Add an error message for BPF filter
Currently there's no error message for filter (other than the help for
the option) when it's built with NO_BPF_SKEL=1. It should show the
BPF filter is not supported like below:
$ sudo ./perf record -e cycles --filter ip==1 true
BPF filter is not supported <------------------- added
Usage: perf record [<options>] [<command>]
or: perf record [<options>] -- <command> [<options>]
--filter <filter>
event filter
Signed-off-by: Namhyung Kim <namhyung@...nel.org>
---
tools/perf/util/parse-events.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 6c5cf5244486..f1fa469712c4 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -2543,8 +2543,16 @@ static int set_filter(struct evsel *evsel, const void *arg)
perf_pmu__scan_file(pmu, "nr_addr_filters",
"%d", &nr_addr_filters);
- if (!nr_addr_filters)
- return perf_bpf_filter__parse(&evsel->bpf_filters, str);
+ if (!nr_addr_filters) {
+ int ret = perf_bpf_filter__parse(&evsel->bpf_filters, str);
+
+ if (ret == -EOPNOTSUPP)
+ fprintf(stderr, "BPF filter is not supported\n");
+ else if (ret)
+ fprintf(stderr, "failed to set the BPF filter\n");
+
+ return ret;
+ }
if (evsel__append_addr_filter(evsel, str) < 0) {
fprintf(stderr,
--
2.40.0.rc1.284.g88254d51c5-goog
Powered by blists - more mailing lists