From: sashiko-bot@kernel.org
To: "Kunwu Chan" <kunwu.chan@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [RFC PATCH 4/5] selftests/perf_events: add userspace AUX regression test
Date: Fri, 14 Aug 2026 14:59:13 +0000 [thread overview]
Message-ID: <20260814145913.7E16D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260814144927.489172-5-kunwu.chan@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Multiple test functions have fundamental logic flaws that cause them to vacuously pass or unconditionally skip, failing to validate the AUX buffer behavior they are intended to test.
--
--- Patch [4]: [RFC PATCH 4/5] selftests/perf_events: add userspace AUX regression test ---
commit d0e63b73f16bd8ebf0771524fc82ef084c85ea92
Author: Lian Wang <lianux.mm@gmail.com>
selftests/perf_events: add userspace AUX regression test
This commit adds a standalone C program to test the perf event AUX userspace
mmap protocol. It opens a perf event, mmaps the metadata/data rings, and sets
up the AUX area to ensure kernel-side changes do not break existing behavior.
> diff --git a/tools/testing/selftests/perf_events/aux_kernel_usermode.c b/tools/testing/selftests/perf_events/aux_kernel_usermode.c
> new file mode 100644
> index 0000000000000..c3d2323d08797
> --- /dev/null
> +++ b/tools/testing/selftests/perf_events/aux_kernel_usermode.c
[ ... ]
> @@ -267,23 +267,23 @@ static int test_aux_mmap_independence(int pmu_type)
> mp1 = mmap(NULL, aux_size + getpagesize(), PROT_READ | PROT_WRITE,
> MAP_SHARED, fd1, 0);
> if (mp1 == MAP_FAILED) {
> FAIL("AUX independence: first mmap failed (%s)", strerror(errno));
> close(fd1);
> return 1;
> }
> PASS("AUX independence: first event mmap OK");
>
> /* Open a second event for the same PMU */
> fd2 = perf_event_open(&attr, 0, -1, -1, 0);
[Severity: Medium]
Does test_aux_mmap_independence() actually allocate an AUX buffer? This code
only mmaps the standard perf metadata/data ring. It appears to omit the setup
and second mmap() calls required to actually allocate an AUX buffer for either
file descriptor.
[ ... ]
> @@ -359,20 +359,20 @@ static int test_mmap_page_fields(int pmu_type)
> if (mp->compat_version != 0) {
> FAIL("mmap fields: compat_version=%u (expected 0)",
> mp->compat_version);
> munmap(mp, total_size + getpagesize());
> close(fd);
> return 1;
> }
> PASS("mmap fields: compat_version=%u", mp->compat_version);
>
> if (mp->aux_offset == 0) {
> printf(" [SKIP] mmap fields: aux_offset is 0 (no AUX area)\n");
> munmap(mp, total_size + getpagesize());
> close(fd);
> return 0;
> }
[Severity: Medium]
Does this cause test_mmap_page_fields() to unconditionally skip? The aux_offset
is a user-space defined field, but this checks it immediately after the primary
mmap() when the kernel has zero-initialized the page.
[ ... ]
> @@ -411,20 +411,20 @@ static int test_aux_head_monotonic(int pmu_type)
>
> attr.type = pmu_type;
> attr.size = sizeof(attr);
> attr.disabled = 1;
> attr.sample_period = 256;
> attr.freq = 0;
>
> fd = perf_event_open(&attr, 0, -1, -1, 0);
> if (fd < 0) {
> /* Some PMUs may reject the default config */
> PASS("AUX head monotonic: skipped (PMU rejected config)");
> return 0;
> }
[Severity: Medium]
Should this use a skip or fail mechanism instead? Returning PASS on a failure to
open the event could mask regressions and inflate the pass rate.
[ ... ]
> @@ -443,20 +443,20 @@ static int test_aux_head_monotonic(int pmu_type)
> if (aux_base == MAP_FAILED) {
> printf(" [SKIP] AUX head monotonic: AUX area mmap failed (%s)\n",
> strerror(errno));
> munmap(mp, mmap_size);
> close(fd);
> return 0;
> }
>
> ret = ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);
> if (ret < 0) {
> PASS("AUX head monotonic: skipped (enable failed)");
> munmap(aux_base, aux_size);
> munmap(mp, mmap_size);
> close(fd);
> return 0;
> }
[Severity: Medium]
Similarly, should this report a skip or failure instead of PASS when the event
fails to enable?
[ ... ]
> @@ -453,20 +453,20 @@ static int test_aux_head_monotonic(int pmu_type)
> }
>
> /* Read initial head */
> head_before = __atomic_load_n(&mp->aux_head, __ATOMIC_RELAXED);
>
> usleep(100000); /* 100ms */
>
> head_after = __atomic_load_n(&mp->aux_head, __ATOMIC_RELAXED);
>
> ioctl(fd, PERF_EVENT_IOC_DISABLE, 0);
>
> if (head_after >= head_before) {
> PASS("AUX head monotonic: before=%lu after=%lu (OK)",
> head_before, head_after);
> } else {
> /* Wrapping is OK for very long runs */
> PASS("AUX head monotonic: before=%lu after=%lu (wrapped)",
> head_before, head_after);
> }
[Severity: Medium]
How does this verify that the head was monotonically increasing? Since both
branches result in PASS, the test doesn't seem to assert any failure condition
or ensure that AUX data was actually generated.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260814144927.489172-1-kunwu.chan@linux.dev?part=4
next prev parent reply other threads:[~2026-08-14 14:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 14:49 [RFC PATCH 0/5] perf/core: add AUX buffer kernel-consumer API Kunwu Chan
2026-08-14 14:49 ` [RFC PATCH 1/5] perf/core: add AUX buffer ownership for kernel events Kunwu Chan
2026-08-14 15:04 ` sashiko-bot
2026-08-14 14:49 ` [RFC PATCH 2/5] perf/core: add AUX ring accessors for kernel consumers Kunwu Chan
2026-08-14 14:59 ` sashiko-bot
2026-08-14 14:49 ` [RFC PATCH 3/5] perf/core: add KUnit tests for AUX kernel-consumer API Kunwu Chan
2026-08-14 15:02 ` sashiko-bot
2026-08-14 14:49 ` [RFC PATCH 4/5] selftests/perf_events: add userspace AUX regression test Kunwu Chan
2026-08-14 14:59 ` sashiko-bot [this message]
2026-08-14 14:49 ` [RFC PATCH 5/5] selftests/perf_events: add AUX kernel API selftest script Kunwu Chan
2026-08-14 14:56 ` 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=20260814145913.7E16D1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kunwu.chan@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.