From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v3 11/11] perf tests: Add round-trip export, CPUID symlink, and pmu-events.dir overlay tests
Date: Fri, 04 Dec 2026 01:49:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-248914@kernel.org> (raw)
In-Reply-To: <20261204011029.1946921-12-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 7 potential
issues to consider:
- [Medium] perf tests: lazy event lookup checks bypassed by eager load
in test_pmu_get()
- [Medium] perf tests: default_core override skip test is vacuous due to
unsorted list
- [Medium] perf tests: in-process PERF_CPUID change poisons
map_for_cpu() cache
- [Medium] perf tests: TopdownL1 override test lacks compiled-in
description
- [Medium] perf tests: test_jevents_output_dir() silently passes via
compiled-in testcpu
- [Low] perf tests: commit message CPUID symlink names do not match
pmu.c
- [Low] perf tests: TEST_ASSERT_EQUAL double-evaluates cmd_list() on
failure
--
commit ddffa1a39a027631013d4b7a55af782aea331936
Author: Ian Rogers <irogers@google.com>
perf tests: Add round-trip export, CPUID symlink, and pmu-events.dir overlay tests
This commit adds C unit tests in tools/perf/tests/pmu.c and a shell test
suite in tools/perf/tests/shell/pmu_events_dir.sh to exercise layered
pmu-events.dir overlays, CPUID symlinks, and perf list export options.
> - In tools/perf/tests/pmu.c (Layered PMU directory overlays):
> Test colon-separated pmu-events.dir overlays via perfconfig, base
> (cpus/GenuineIntel-6-99 -> ../models/x86/mock_arch) and
> stepping-specific (cpus/GenuineIntel-6-99-4 ->
> ../models/x86/mock_arch_step4) CPUID POSIX symlinks via PERF_CPUID
> without mapfile.csv, single-file attribute overrides preserving
[Severity: Low]
The CPUID symlink names here don't match what run_pmu_layer_overlay_checks()
creates. The code uses dir2/cpus/GenuineTest-6-AA -> ../models/testmodel
and dir2/cpus/GenuineTest-6-AA-1 -> ../models/stepping1 with PERF_CPUID set
to GenuineTest-6-AA-1.
> diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c
> index f208932590dff..fc2a92dbb2b3d 100644
> --- a/tools/perf/tests/pmu.c
> +++ b/tools/perf/tests/pmu.c
> @@ -628,6 +634,958 @@ static int test__pmu_match(struct test_suite *test __maybe_unused, int subtest _
[ ... ]
> + TEST_ASSERT_VAL("setenv PERF_CPUID",
> + setenv("PERF_CPUID", "GenuineTest-6-AA-1", 1) == 0);
> + perf_config__exit();
> + perf_pmus__destroy();
[Severity: Medium]
Can mutating PERF_CPUID in-process poison map_for_cpu()'s static cache
under perf test -F?
map_for_cpu() caches last_result keyed only by cpu.cpu without checking
whether PERF_CPUID changed, and perf_pmus__destroy() does not invalidate it.
In no-fork mode, earlier subtests in suite__pmu cache the host table for
cpu -1, leaking it into this test, and the later test_pmu_get() call while
PERF_CPUID is GenuineTest-6-AA-1 leaves a NULL entry cached for cpu -1 for
subsequent suites such as suite__pmu_events.
> +
> + pmu = test_pmu_get(sysfs_dir, sysfs_dir_sz);
> + *pmu_out = pmu;
> + TEST_ASSERT_VAL("test_pmu_get", pmu != NULL);
> +
> + /*
> + * 1-3. Exercise lazy single-event lookup (before perf_pmu__for_each_event()
> + * enumerates all events), then verify full enumeration metadata.
> + */
[Severity: Medium]
Doesn't test_pmu_get() eagerly load all events before sections 1-3 run,
bypassing the lazy single-event lookup path?
test_pmu_get() calls perf_pmus__add_test_pmu() ->
perf_pmu__lookup(..., /*eager_load=*/true) -> pmu_layer__load_events_at(),
which enumerates all layers and sets pmu->aliases_loaded = true. Every
subsequent perf_pmu__have_event() and parse_events() call then
short-circuits in pmu_layer__find_event() without reaching
layer->ops->find_event(), and perf_pmu__num_events() returns early without
testing a lazy-to-full-scan transition.
[ ... ]
> + mg_desc = perf_pmus__describe_metricgroup("TopdownL1");
> + TEST_ASSERT_VAL("per-PMU user TopdownL1.desc beats compiled-in",
> + mg_desc && !strcmp(mg_desc, "Overridden TopdownL1 on tool PMU"));
[Severity: Medium]
Is there actually a compiled-in TopdownL1 description present here to test
override precedence against?
With PERF_CPUID set to GenuineTest-6-AA-1, no compiled-in CPU metrics table
matches, and the common fallback table has no metricgroup descriptions.
builtin_desc in perf_pmus__describe_metricgroup() is therefore NULL, so a
precedence regression against compiled-in descriptions would still pass.
[ ... ]
> + TEST_ASSERT_VAL("find_metric_pmu default_core skips per-PMU override",
> + perf_pmus__find_metric_pmu("default_core", "het_coexist_m", &found_m) &&
> + found_m.metric_expr &&
> + !strcmp(found_m.metric_expr, "duration_time + 40"));
[Severity: Medium]
Does this assertion ever visit aa_het_core_0 before returning?
Earlier perf_pmus__scan_core() and perf_pmus__find_metric() calls already
populate and sort core_pmus with the host or placeholder core PMU and mark
read_pmu_types complete. perf_pmus__add_test_pmu() then appends
aa_het_core_0 via list_add_tail() without re-sorting, so
perf_pmus__find_metric_pmu() (and export_find_pmu_metric() during
cmd_list --export-dir) matches the shared default_core metric on the first
core PMU and returns without exercising per-PMU override skipping.
[ ... ]
> + TEST_ASSERT_EQUAL("cmd_list --export-dir metric",
> + cmd_list(4, export_argv), 0);
[Severity: Low]
Will this crash with a NULL pointer dereference if cmd_list() fails?
TEST_ASSERT_EQUAL() evaluates its val argument a second time in pr_debug()
when the check fails. The first cmd_list() call runs parse_options_end(),
which mutates export_argv so export_argv[1] is NULL, causing the second
call to dereference NULL in parse_options_step(). Storing the return value
in a local variable before passing it to TEST_ASSERT_EQUAL() avoids the
double evaluation.
> diff --git a/tools/perf/tests/shell/pmu_events_dir.sh b/tools/perf/tests/shell/pmu_events_dir.sh
> new file mode 100755
> index 0000000000000..ffca18e674fb3
> --- /dev/null
> +++ b/tools/perf/tests/shell/pmu_events_dir.sh
> @@ -0,0 +1,236 @@
[ ... ]
> + PERF_CPUID=testcpu PERF_CONFIG="${tmpdir}/jevents_config" \
> + perf list > "${tmpdir}/jevents_list.txt" 2>/dev/null
> + grep -q "bp_l1_btb_correct" "${tmpdir}/jevents_list.txt"
> + grep -q "dcache_miss_cpi" "${tmpdir}/jevents_list.txt"
[Severity: Medium]
Do these grep checks verify that perf actually loaded the jevents-test
directory?
Both bp_l1_btb_correct and dcache_miss_cpi are unconditionally present in
the compiled-in testcpu table (even with NO_JEVENTS=1), so the test passes
even if perf ignores tmpdir/jevents-test or a symlink is dangling.
Mutating a generated sidecar like test_export_cpuid() does would verify
that the directory was loaded.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204011029.1946921-1-irogers@google.com?part=11
next prev parent reply other threads:[~2026-12-04 1:49 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 1:10 [PATCH v3 00/11] perf pmu: Layered sysfs-style PMU event and metric directories Ian Rogers
2026-12-04 1:10 ` [PATCH v3 01/11] perf pmu: Generalize pmu_alias_info_file() and lazy single-event sysfs loading Ian Rogers
2026-12-04 1:32 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 02/11] perf pmu: Add metric and metricgroup storage on struct perf_pmu Ian Rogers
2026-12-04 1:26 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 03/11] perf pmu-layer: Introduce stateless struct pmu_layer abstraction and builtin adapter Ian Rogers
2026-12-04 1:35 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 04/11] perf pmu-layer: Add openat-based directory layer with literal CPUID/symlink lookup Ian Rogers
2026-12-04 1:35 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 05/11] perf config: Add pmu-events.dir configuration option Ian Rogers
2026-12-04 1:27 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 06/11] perf pmu: Switch alias resolution and enumeration to layered PMU stack Ian Rogers
2026-12-04 1:38 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 07/11] perf metricgroup: Route metric and metricgroup lookups through struct perf_pmu Ian Rogers
2026-12-04 1:40 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 08/11] perf list, jevents: Add --export-dir and --output-dir sysfs-style exporters Ian Rogers
2026-12-04 1:36 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 09/11] perf jevents: Add compiled-in model and sys table iterators Ian Rogers
2026-12-04 1:10 ` [PATCH v3 10/11] perf list: Add --export-cpuid to export compiled-in CPU models Ian Rogers
2026-12-04 1:44 ` sashiko-bot
2026-12-04 1:10 ` [PATCH v3 11/11] perf tests: Add round-trip export, CPUID symlink, and pmu-events.dir overlay tests Ian Rogers
2026-12-04 1:49 ` sashiko-bot [this message]
2026-12-04 1:49 ` [PATCH v3 00/11] perf pmu: Layered sysfs-style PMU event and metric directories 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-248914@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=irogers@google.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.