From: sashiko-bot@kernel.org
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 01/17] perf tests top: Pin the ring buffer size
Date: Tue, 24 Nov 2026 19:01:01 +0000 [thread overview]
Message-ID: <sashiko-outbox-231870@kernel.org> (raw)
In-Reply-To: <20261124184604.24983-2-acme@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] perf tests top: -m 128 assumes 4K pages and can fail with
EPERM on 64K kernels
- [Medium] perf tests top: BPF sideband evlist ignores -m and uses
perf_event_mlock_kb
--
commit a27a5c7becc862ff1f80abad85898b11bfc88147
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
perf tests top: Pin the ring buffer size
This commit passes -m 128 to the perf top invocations in top.sh so the ring
buffer size does not scale with host kernel.perf_event_mlock_kb settings.
> diff --git a/tools/perf/tests/shell/top.sh b/tools/perf/tests/shell/top.sh
> index 3d52677ccb5fd..4808d79275178 100755
> --- a/tools/perf/tests/shell/top.sh
> +++ b/tools/perf/tests/shell/top.sh
> @@ -19,6 +19,9 @@ trap_cleanup() {
> }
> trap trap_cleanup EXIT TERM INT
>
> +# perf top sizes its default ring buffer from kernel.perf_event_mlock_kb,
> +# which a test host may have tuned large, pin it to the upstream default
> +# of 128 pages (516 KiB) so the test does not depend on the host setting.
> test_basic_perf_top() {
> echo "Basic perf top test"
>
> @@ -36,7 +39,7 @@ test_basic_perf_top() {
> # Use -e cpu-clock to ensure we get samples
> # Use sleep to keep stdin open but silent, preventing EOF loop or interactive spam
> retval=0
> - sleep 10 | timeout 5s perf top --stdio -d 1 -e cpu-clock \
> + sleep 10 | timeout 5s perf top --stdio -d 1 -m 128 -e cpu-clock \
> -p $PID > "${log_file}" 2>&1 || retval=$?
[Severity: Medium]
Can passing -m 128 cause perf top to fail with EPERM on 64K page kernels?
parse_pages_arg() treats a bare integer without a unit suffix as a page
count rather than a byte size, whereas the upstream default
sysctl_perf_event_mlock is 512 + (PAGE_SIZE / 1024) KiB (only 8 data pages
plus 1 control page per CPU on 64K page kernels). On a 64K page kernel,
-m 128 requests 8,256 KiB per ring buffer (16,512 KiB across the two
thloop threads), which can exceed the default per-CPU mlock budget and the
8 MiB RLIMIT_MEMLOCK for an unprivileged user.
Passing -m 512K in both test_basic_perf_top() and
test_hybrid_merge_perf_top() would pin the data buffer to 512 KiB
regardless of the kernel page size.
> @@ -83,7 +86,7 @@ test_hybrid_merge_perf_top() {
> # environments can seamlessly fall back to cpu-clock while real
> # hybrid hardware will naturally cover the merge logic.
> retval=0
> - sleep 10 | timeout 5s perf top \
> + sleep 10 | timeout 5s perf top -m 128 \
> --stdio --hybrid-merge -d 1 -p $PID > "${log_file}" 2>&1 || retval=$?
[Severity: Medium]
Does the BPF sideband evlist in perf top still size its ring buffers from
kernel.perf_event_mlock_kb even when -m is passed?
Before __cmd_top() maps top.evlist with opts->mmap_pages, cmd_top() starts
the BPF sideband thread via evlist__start_sb_thread(top.sb_evlist, target),
which calls evlist__do_mmap(evlist, UINT_MAX). With UINT_MAX,
evlist__mmap_size() falls back to perf_event_mlock_kb_in_pages(), so on a
host with a large kernel.perf_event_mlock_kb setting, top.sb_evlist still
maps two huge ring buffers for the thloop threads and can exhaust memory
or the mlock budget before top.evlist is mapped.
Passing --no-bpf-event to both perf top invocations (or sizing the
sideband evlist intelligently) would avoid depending on
kernel.perf_event_mlock_kb.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124184604.24983-1-acme@kernel.org?part=1
next prev parent reply other threads:[~2026-11-24 19:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 18:45 [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 01/17] perf tests top: Pin the ring buffer size Arnaldo Carvalho de Melo
2026-11-24 19:01 ` sashiko-bot [this message]
2026-11-24 18:45 ` [PATCH v1 02/17] perf tests sched: Exercise the sched views and options Arnaldo Carvalho de Melo
2026-11-24 18:58 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 03/17] perf tests help: Add a basic perf help test Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 04/17] perf tests config: Exercise the config file and list options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 05/17] perf tests script: Exercise the list, fields and dump options Arnaldo Carvalho de Melo
2026-11-24 18:54 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 06/17] perf tests sort: Exercise the report and diff sort keys Arnaldo Carvalho de Melo
2026-11-24 19:02 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 07/17] perf tests diff: Exercise the output options Arnaldo Carvalho de Melo
2026-11-24 18:57 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 08/17] perf tests annotate: Exercise the output and filter options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 09/17] perf tests report: Exercise the output and format options Arnaldo Carvalho de Melo
2026-11-24 18:45 ` [PATCH v1 10/17] perf tests record: Exercise more record options Arnaldo Carvalho de Melo
2026-11-24 19:03 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 11/17] perf tests trace: Exercise the tracing options Arnaldo Carvalho de Melo
2026-11-24 19:02 ` sashiko-bot
2026-11-24 18:45 ` [PATCH v1 12/17] perf tests timechart: Exercise the report options Arnaldo Carvalho de Melo
2026-11-24 18:46 ` [PATCH v1 13/17] perf tests kmem: Add a basic perf kmem test Arnaldo Carvalho de Melo
2026-11-24 18:57 ` sashiko-bot
2026-11-24 18:46 ` [PATCH v1 14/17] perf tests bench: Add smoke tests for perf bench Arnaldo Carvalho de Melo
2026-11-24 19:03 ` sashiko-bot
2026-11-24 18:46 ` [PATCH v1 15/17] perf tests lock: Exercise perf lock report and info Arnaldo Carvalho de Melo
2026-11-24 18:46 ` [PATCH v1 16/17] perf tests probe: Exercise the variable and line listing Arnaldo Carvalho de Melo
2026-11-24 19:00 ` sashiko-bot
2026-11-24 18:46 ` [PATCH v1 17/17] perf tests report: Exercise the TUI browsers Arnaldo Carvalho de Melo
2026-11-24 19:01 ` sashiko-bot
2026-11-24 19:03 ` [PATCH v1 00/17] perf tests: Add coverage for the untested perf subcommands sashiko-bot
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=sashiko-outbox-231870@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=acme@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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