From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
Kan Liang <kan.liang@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org
Subject: [PATCH 8/8] perf test: Update sample filtering test
Date: Fri, 21 Jun 2024 15:23:57 -0700 [thread overview]
Message-ID: <20240621222357.717374-9-namhyung@kernel.org> (raw)
In-Reply-To: <20240621222357.717374-1-namhyung@kernel.org>
Now it can run the BPF filtering test with normal user if the BPF
objects are pinned by 'sudo perf record --setup-filter pin'. Let's
update the test case to verify the behavior. It'll skip the test if the
filter check is failed from a normal user, but it shows a message how to
set up the filters.
First, run the test as a normal user and it fails.
$ perf test -vv filtering
95: perf record sample filtering (by BPF) tests:
--- start ---
test child forked, pid 425677
Checking BPF-filter privilege
try 'sudo perf record --setup-filter pin' first. <<<--- here
bpf-filter test [Skipped permission]
---- end(-2) ----
95: perf record sample filtering (by BPF) tests : Skip
According to the message, run the perf record command to pin the BPF
objects.
$ sudo perf record --setup-filter pin
And re-run the test as a normal user.
$ perf test -vv filtering
95: perf record sample filtering (by BPF) tests:
--- start ---
test child forked, pid 424486
Checking BPF-filter privilege
Basic bpf-filter test
Basic bpf-filter test [Success]
Failing bpf-filter test
Error: task-clock event does not have PERF_SAMPLE_CPU
Failing bpf-filter test [Success]
Group bpf-filter test
Error: task-clock event does not have PERF_SAMPLE_CPU
Error: task-clock event does not have PERF_SAMPLE_CODE_PAGE_SIZE
Group bpf-filter test [Success]
---- end(0) ----
95: perf record sample filtering (by BPF) tests : Ok
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/shell/record_bpf_filter.sh | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tools/perf/tests/shell/record_bpf_filter.sh b/tools/perf/tests/shell/record_bpf_filter.sh
index 31c593966e8c..c5882d620db7 100755
--- a/tools/perf/tests/shell/record_bpf_filter.sh
+++ b/tools/perf/tests/shell/record_bpf_filter.sh
@@ -22,15 +22,16 @@ trap trap_cleanup EXIT TERM INT
test_bpf_filter_priv() {
echo "Checking BPF-filter privilege"
- if [ "$(id -u)" != 0 ]
- then
- echo "bpf-filter test [Skipped permission]"
- err=2
- return
- fi
if ! perf record -e task-clock --filter 'period > 1' \
-o /dev/null --quiet true 2>&1
then
+ if [ "$(id -u)" != 0 ]
+ then
+ echo "try 'sudo perf record --setup-filter pin' first."
+ echo "bpf-filter test [Skipped permission]"
+ err=2
+ return
+ fi
echo "bpf-filter test [Skipped missing BPF support]"
err=2
return
--
2.45.2.741.gdbec12cfda-goog
next prev parent reply other threads:[~2024-06-21 22:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 22:23 [RFC/PATCHSET 0/8] perf record: Use a pinned BPF program for filter (v2) Namhyung Kim
2024-06-21 22:23 ` [PATCH 1/8] perf bpf-filter: Make filters map a single entry hashmap Namhyung Kim
2024-06-21 22:23 ` [PATCH 2/8] perf bpf-filter: Pass 'target' to perf_bpf_filter__prepare() Namhyung Kim
2024-06-21 22:23 ` [PATCH 3/8] perf bpf-filter: Split per-task filter use case Namhyung Kim
2024-06-21 22:23 ` [PATCH 4/8] perf bpf-filter: Support pin/unpin BPF object Namhyung Kim
2024-06-21 22:23 ` [PATCH 5/8] perf bpf-filter: Support separate lost counts for each filter Namhyung Kim
2024-06-21 22:23 ` [PATCH 6/8] perf record: Fix a potential error handling issue Namhyung Kim
2024-06-21 22:23 ` [PATCH 7/8] perf record: Add --setup-filter option Namhyung Kim
2024-06-21 22:23 ` Namhyung Kim [this message]
2024-06-21 22:34 ` [RFC/PATCHSET 0/8] perf record: Use a pinned BPF program for filter (v2) Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240621222357.717374-9-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox