From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ian Rogers <irogers@google.com>,
Kan Liang <kan.liang@linux.intel.com>,
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, KP Singh <kpsingh@kernel.org>,
Song Liu <song@kernel.org>,
bpf@vger.kernel.org, Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH v3 8/8] perf test: Update sample filtering test
Date: Thu, 1 Aug 2024 15:22:25 -0700 [thread overview]
Message-ID: <ZqwKoWpBN9G3u-K0@google.com> (raw)
In-Reply-To: <ZqukTsjWqbx-xZ7L@x1>
On Thu, Aug 01, 2024 at 12:05:50PM -0300, Arnaldo Carvalho de Melo wrote:
> On Wed, Jul 31, 2024 at 05:12:47PM -0700, Namhyung Kim wrote:
> > On Wed, Jul 31, 2024 at 11:10:07AM -0300, Arnaldo Carvalho de Melo wrote:
> > > On Wed, Jul 03, 2024 at 03:30:35PM -0700, Namhyung Kim wrote:
> > > > 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
> > >
> > > Ok, so I tested one of the examples you provide as a root user:
> > >
> > > root@number:~# perf record -o- -e cycles:u --filter 'period < 10' perf test -w noploop | perf script -i-
> > > [ perf record: Woken up 1 times to write data ]
> > > [ perf record: Captured and wrote 0.024 MB - ]
> > > perf-exec 228020 53029.825757: 1 cpu_core/cycles/u: 7fe361d1cc11 [unknown] ([unknown])
> > > perf-exec 228020 53029.825760: 1 cpu_core/cycles/u: 7fe361d1cc11 [unknown] ([unknown])
> > > perf 228020 53029.826313: 1 cpu_atom/cycles/u: 7fd80d7ba040 _start+0x0 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228020 53029.826316: 1 cpu_atom/cycles/u: 7fd80d7ba040 _start+0x0 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228020 53029.838051: 1 cpu_core/cycles/u: 53b062 noploop+0x62 (/home/acme/bin/perf)
> > > perf 228020 53029.838054: 1 cpu_core/cycles/u: 53b062 noploop+0x62 (/home/acme/bin/perf)
> > > perf 228020 53029.838055: 9 cpu_core/cycles/u: 53b062 noploop+0x62 (/home/acme/bin/perf)
> > > perf 228020 53029.844137: 1 cpu_core/cycles/u: 53b05c noploop+0x5c (/home/acme/bin/perf)
> > > perf 228020 53029.844139: 1 cpu_core/cycles/u: 53b05c noploop+0x5c (/home/acme/bin/perf)
> > > root@number:~# perf record -o- -e cycles:u --filter 'period < 100000' perf test -w noploop | perf script -i-
> > > [ perf record: Woken up 1 times to write data ]
> > > [ perf record: Captured and wrote 0.025 MB - ]
> > > perf-exec 228084 53076.760776: 1 cpu_core/cycles/u: 7f7e7691cc11 [unknown] ([unknown])
> > > perf-exec 228084 53076.760779: 1 cpu_core/cycles/u: 7f7e7691cc11 [unknown] ([unknown])
> > > perf-exec 228084 53076.760779: 10 cpu_core/cycles/u: 7f7e7691cc11 [unknown] ([unknown])
> > > perf-exec 228084 53076.760780: 497 cpu_core/cycles/u: 7f7e7691cc11 [unknown] ([unknown])
> > > perf-exec 228084 53076.760781: 27924 cpu_core/cycles/u: 7f7e7691cc11 [unknown] ([unknown])
> > > perf 228084 53076.761318: 1 cpu_atom/cycles/u: 7f317057d040 _start+0x0 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228084 53076.761320: 1 cpu_atom/cycles/u: 7f317057d040 _start+0x0 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228084 53076.761321: 14 cpu_atom/cycles/u: 7f317057d040 _start+0x0 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228084 53076.761322: 518 cpu_atom/cycles/u: 7f317057d040 _start+0x0 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228084 53076.761322: 20638 cpu_atom/cycles/u: 7f317057d040 _start+0x0 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228084 53076.768070: 1 cpu_core/cycles/u: 7f317056e898 _dl_relocate_object+0x1d8 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228084 53076.768072: 1 cpu_core/cycles/u: 7f317056e898 _dl_relocate_object+0x1d8 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228084 53076.768073: 17 cpu_core/cycles/u: 7f317056e898 _dl_relocate_object+0x1d8 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228084 53076.768073: 836 cpu_core/cycles/u: 7f317056e898 _dl_relocate_object+0x1d8 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228084 53076.768074: 44346 cpu_core/cycles/u: 7f317056e89b _dl_relocate_object+0x1db (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228084 53076.843976: 1 cpu_core/cycles/u: 53b05c noploop+0x5c (/home/acme/bin/perf)
> > > perf 228084 53076.843978: 1 cpu_core/cycles/u: 53b05c noploop+0x5c (/home/acme/bin/perf)
> > > perf 228084 53076.843979: 13 cpu_core/cycles/u: 53b05c noploop+0x5c (/home/acme/bin/perf)
> > > perf 228084 53076.843979: 563 cpu_core/cycles/u: 53b05c noploop+0x5c (/home/acme/bin/perf)
> > > perf 228084 53076.843980: 26519 cpu_core/cycles/u: 53b05c noploop+0x5c (/home/acme/bin/perf)
> > > perf 228084 53077.482090: 1 cpu_core/cycles/u: 53b062 noploop+0x62 (/home/acme/bin/perf)
> > > perf 228084 53077.482092: 1 cpu_core/cycles/u: 53b062 noploop+0x62 (/home/acme/bin/perf)
> > > perf 228084 53077.482093: 15 cpu_core/cycles/u: 53b062 noploop+0x62 (/home/acme/bin/perf)
> > > perf 228084 53077.482093: 746 cpu_core/cycles/u: 53b062 noploop+0x62 (/home/acme/bin/perf)
> > > perf 228084 53077.482094: 38315 cpu_core/cycles/u: 53b05c noploop+0x5c (/home/acme/bin/perf)
> > > root@number:~#
> > >
> > > Filtering by period works as advertised, now I have done as root;
> > >
> > > root@number:~# perf record --setup-filter pin
> > > root@number:~# ls -la /sys/fs/bpf/perf_filter/
> > > total 0
> > > drwxr-xr-x. 2 root root 0 Jul 31 10:43 .
> > > drwxr-xr-t. 3 root root 0 Jul 31 10:43 ..
> > > -rw-rw-rw-. 1 root root 0 Jul 31 10:43 dropped
> > > -rw-rw-rw-. 1 root root 0 Jul 31 10:43 filters
> > > -rwxrwxrwx. 1 root root 0 Jul 31 10:43 perf_sample_filter
> > > -rw-rw-rw-. 1 root root 0 Jul 31 10:43 pid_hash
> > > -rw-------. 1 root root 0 Jul 31 10:43 sample_f_rodata
> > > root@number:~# ls -la /sys/fs/bpf/perf_filter/perf_sample_filter
> > > -rwxrwxrwx. 1 root root 0 Jul 31 10:43 /sys/fs/bpf/perf_filter/perf_sample_filter
> > > root@number:~#
> > >
> > > And as a normal user I try:
> > >
> > > acme@number:~$ perf record -o- -e cycles:u perf test -w noploop | perf script -i- | head
> > > [ perf record: Woken up 1 times to write data ]
> > > [ perf record: Captured and wrote 0.204 MB - ]
> > > perf 228218 53158.670585: 1 cpu_atom/cycles/u: 7f2fb1b6e040 _start+0x0 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228218 53158.670590: 1 cpu_atom/cycles/u: 7f2fb1b6e040 _start+0x0 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228218 53158.670592: 7 cpu_atom/cycles/u: 7f2fb1b6e040 _start+0x0 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228218 53158.670593: 117 cpu_atom/cycles/u: 7f2fb1b6e040 _start+0x0 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228218 53158.670595: 2152 cpu_atom/cycles/u: 7f2fb1b6e040 _start+0x0 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228218 53158.670604: 38977 cpu_atom/cycles/u: ffffffff99201280 [unknown] ([unknown])
> > > perf 228218 53158.670650: 167064 cpu_atom/cycles/u: 7f2fb1b67d7c intel_check_word.constprop.0+0x16c (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228218 53158.671472: 232830 cpu_atom/cycles/u: 7f2fb1b75d98 strcmp+0x78 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228218 53158.672710: 191183 cpu_atom/cycles/u: 7f2fb1b59311 _dl_map_object_from_fd+0xea1 (/usr/lib64/ld-linux-x86-64.so.2)
> > > perf 228218 53158.673461: 158125 cpu_atom/cycles/u: 7f2fb1b77148 strcmp+0x1428 (/usr/lib64/ld-linux-x86-64.so.2)
> > > acme@number:~$
> > >
> > > Ok, no filtering, bot samples, lets try to use filtering as with root:
> > >
> > > acme@number:~$ perf record -o- -e cycles:u --filter 'period < 10000000' perf test -w noploop | perf script -i-
> > > [ perf record: Woken up 1 times to write data ]
> > > [ perf record: Captured and wrote 0.019 MB - ]
> > > acme@number:~$ perf record -o- -e cycles:u --filter 'period < 10000000' perf test -w noploop | perf script -i-
> > > [ perf record: Woken up 1 times to write data ]
> > > [ perf record: Captured and wrote 0.019 MB - ]
> > > acme@number:~$ perf record -o- -e cycles:u --filter 'period < 10000000' perf test -w noploop | perf script -i-
> > > [ perf record: Woken up 1 times to write data ]
> > > [ perf record: Captured and wrote 0.019 MB - ]
> > > acme@number:~$ perf record -o- -e cycles:u --filter 'period < 10000000' perf test -w noploop | perf script -i-
> > > [ perf record: Woken up 1 times to write data ]
> > > [ perf record: Captured and wrote 0.019 MB - ]
> > > acme@number:~$
> >
> > Hmm.. strange. The above command works well for me.
> >
> > >
> > > acme@number:~$ perf record -v -e cycles:u --filter 'period < 10000000' perf test -w noploop
> > > Using CPUID GenuineIntel-6-B7-1
> > > DEBUGINFOD_URLS=
> > > nr_cblocks: 0
> > > affinity: SYS
> > > mmap flush: 1
> > > comp level: 0
> > > Problems creating module maps, continuing anyway...
> > > pid hash: 228434 -> 13
> > > pid hash: 228434 -> 14
> >
> > This part is a little strange as it's using two entries. Hmm, are you
> > using a hybrid machine? Anyway I think it should work there too..
>
> Yes, I'll try it again on a 5950x since it isn't hybrid.
>
> > Also the number is too high.. I expect 1 or 2. Maybe it didn't release
> > all the entries. Let me think about the case.
>
> I'm inclined for now to keep this series merged and then take fixes on
> top, please advise if this isn't ok with you.
No objections, I'll investigate why it failed on your machine..
Thanks,
Namhyung
next prev parent reply other threads:[~2024-08-01 22:22 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-03 22:30 [PATCHSET v3 0/8] perf record: Use a pinned BPF program for filter Namhyung Kim
2024-07-03 22:30 ` [PATCH v3 1/8] perf bpf-filter: Make filters map a single entry hashmap Namhyung Kim
2024-07-24 18:55 ` Arnaldo Carvalho de Melo
2024-07-24 20:14 ` Namhyung Kim
2024-07-24 19:32 ` Arnaldo Carvalho de Melo
2024-07-24 20:20 ` Namhyung Kim
2024-07-24 21:39 ` Arnaldo Carvalho de Melo
2024-07-26 1:41 ` Namhyung Kim
2024-07-03 22:30 ` [PATCH v3 2/8] perf bpf-filter: Pass 'target' to perf_bpf_filter__prepare() Namhyung Kim
2024-07-03 22:30 ` [PATCH v3 3/8] perf bpf-filter: Split per-task filter use case Namhyung Kim
2024-07-03 22:30 ` [PATCH v3 4/8] perf bpf-filter: Support pin/unpin BPF object Namhyung Kim
2024-07-03 22:30 ` [PATCH v3 5/8] perf bpf-filter: Support separate lost counts for each filter Namhyung Kim
2024-07-03 22:30 ` [PATCH v3 6/8] perf record: Fix a potential error handling issue Namhyung Kim
2024-07-03 22:30 ` [PATCH v3 7/8] perf record: Add --setup-filter option Namhyung Kim
2024-07-03 22:30 ` [PATCH v3 8/8] perf test: Update sample filtering test Namhyung Kim
2024-07-31 14:10 ` Arnaldo Carvalho de Melo
2024-08-01 0:12 ` Namhyung Kim
2024-08-01 15:05 ` Arnaldo Carvalho de Melo
2024-08-01 22:22 ` Namhyung Kim [this message]
2024-08-02 17:43 ` Namhyung Kim
2024-07-23 23:48 ` [PATCHSET v3 0/8] perf record: Use a pinned BPF program for filter 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=ZqwKoWpBN9G3u-K0@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=bpf@vger.kernel.org \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=song@kernel.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;
as well as URLs for NNTP newsgroup(s).