From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796348963; b=BUxxRJJJPM6UU8ecnD6f57Xt9MAUDcd/ZasvjwqNu7vhMm5eESpUZ8g8Fb309yPz/LPz hUkb+lzZaJSld0aaHq0YVNULY48a69rbdj88luDE81byGH2w9vg/FFt5lBnzoLqY/H+Rs p2tGKxMxMagozu5A9aOz4iiOQuECDrtv83+Ba18O6+8YX5s7vZzZ+x+xfKR24yU3dxEO5 n2tJMnYp8jhhj2Um6ZthaJE59evGSGlr85RNQT6kzKE09bRg2RCoBbnmaM/2PgUqqZgH5 CEcdj7f0DT40yRgQp1rbXLHPZOJpA5d6no9/iqCrUoxEuCDwTa3nIFm6tU6TFV5mbgg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796348963; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=5tBbA+FQzysMzg/GlB2K1p8uthTGMMLaFww3B8qK5as=; b=oKjcvTa1r4Kfe7qOoCHJOUu+nP01VTpiqZ1oBy0AHgK9Bp17kI00Imc+lMY7PqIwSJ7/ 1a07RgKcYFs+SjEKJwDbPSLDUNrQ6NhxOJKWpZ+7GIjpbg3cpMbCOrqn1XEiQ3/aWZFzz Q5azofZW18M+/bfINQ/VDStTT3Gu2UPZDy7EjpH1C/nIaVcWuGd/HVZArH76CYRBo0PtT yBbSnObqNtV2xrQTExPaYGo78nxjhWY5fXSqodMBkIn9+LM4gN3dUb1FJIA3d6eABqfsu LED/RCNH9o4Ibd1QW+txbUlHgoLaoBrnejDcMuv/AjY31oN2AHviLcohDJJqWuxfxzw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bCL7ACyS; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3E1D606A32C for ; Fri, 4 Dec 2026 01:49:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bCL7ACyS Received: by smtp.kernel.org (Postfix) with ESMTPSA id 849DB1F000C2; Fri, 4 Dec 2026 01:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796348962; bh=5tBbA+FQzysMzg/GlB2K1p8uthTGMMLaFww3B8qK5as=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=bCL7ACySwNpBbMI25BPGlqoCT0q4rId2jTSJN+35DBiHDcn9uF/Lb5hDHtYI+b3JJ s+ljVnncZS692w0XrHZsDFJ13eT+zgVZrXvilCFGhQoydk3qJofh29qz7Hi+UZtL0P J7FKov37OM3U6GzvvZvo0nmoFHVDMtP9bfSyfZ/6vYf1BIizKSrbjGqBD4L6EkZyFf l8el+7kwl+43UjfRRIV6qxq6BTUQfRw1k2lvT9Nixkjb2pyxWYK5dur6g8Jaqkg8d7 oP55DUeycwaPRn0r+jZsVJ54PesTJDwoFP7dBQYNkXxJGxmnWypk/z7xLh0kv1vyo9 nzSRkA91RYQ+g== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 11/11] perf tests: Add round-trip export, CPUID symlink, and pmu-events.dir overlay tests Reply-To: sashiko-reviews@lists.linux.dev To: "Ian Rogers" Cc: linux-perf-users@vger.kernel.org In-Reply-To: <20261204011029.1946921-12-irogers@google.com> References: <20261204011029.1946921-1-irogers@google.com> <20261204011029.1946921-12-irogers@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 01:49:22 +0000 X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 perf tests: Add round-trip export, CPUID symlink, and pmu-events.dir overla= y 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) =3D=3D 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 =3D test_pmu_get(sysfs_dir, sysfs_dir_sz); > + *pmu_out =3D pmu; > + TEST_ASSERT_VAL("test_pmu_get", pmu !=3D NULL); > + > + /* > + * 1-3. Exercise lazy single-event lookup (before perf_pmu__for_each_ev= ent() > + * 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=3D*/true) -> pmu_layer__load_events_at(), which enumerates all layers and sets pmu->aliases_loaded =3D 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 =3D 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=3Dtestcpu PERF_CONFIG=3D"${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=3D1), 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204011029.1946= 921-1-irogers@google.com?part=3D11