From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Ian Rogers <irogers@google.com>
Subject: [PATCH 0/8] perf build: Avoid pmu-events copies and improve build parallelism
Date: Sat, 5 Dec 2026 18:11:39 -0800 [thread overview]
Message-ID: <20261206021147.3036701-1-irogers@google.com> (raw)
This series removes the copy of ~1,013 checked-in pmu-events JSON/CSV
files into $(OUTPUT) during out-of-tree builds, hardens pmu-events file
discovery against stray and backup files, and removes several
serialization bottlenecks in the perf build and build-test:
- Patches 1-3 (no-copy pmu-events overlay & hardening):
* Ignore hidden, backup, non-list, and generated JSON files in
metric.py and jevents.py.
* Refactor jevents.py directory scanning and add --gen-dir,
--gen-manifest, and --gen-file overlay options so generated JSONs
live in $(OUTPUT)pmu-events/gen/ for both in-tree and out-of-tree
builds without copying checked-in sources or polluting the source
tree.
* Track input file lists with write-if-changed manifests via GNU
Make's $(file ...) built-in, derive model lists from mapfile.csv,
and drop the 1,013 per-file COPY rules and orphan-pruning logic.
* Preserves byte-for-byte identical pmu-events.c and
pmu-events-string.c outputs (and Python-free NO_JEVENTS=1 builds).
- Patches 4-6 (pmu-events generation & test parallelism):
* Scope LoadAllModelEvents() via mapfile.csv so AMD models do not
parse Intel event JSONs and vice versa (and ARM stays scoped to its
vendor), add --output-dir batch mode to amd_metrics.py,
arm64_metrics.py, and intel_metrics.py, and add unit tests in
metric_test.py.
* Replace 136 per-model/per-file metric generation rules in
pmu-events/Build with 3 parallel stamp-gated batch invocations
(~0.5 s wall time for all 136 JSONs: 87 ms AMD, 121 ms ARM64,
503 ms Intel).
* Move EMPTY_PMU_EVENTS_TEST_LOG and METRIC_TEST_LOG off pmu-events.c
onto pmu-events-in.o so tests run in parallel with jevents.py and C
compilation.
- Patch 7 (header-only prepare dependencies):
* Split phony lib{api,bpf,perf,subcmd,symbol}-headers targets running
only install_headers out of the full archive rules in Makefile.perf
(updating bpf_skel.mak to depend on bpf_helper_defs.h instead of
libbpf.a).
* Use those header targets in prepare and libperf-headers in
LIBPMU_EVENTS_IN so library archive builds run in parallel with perf
object compilation and pmu-events.
- Patch 8 (build-test linter deduplication):
* Pass NO_SHELLCHECK=1 NO_MYPY=1 NO_PYLINT=1 to all targets in
tools/perf/tests/make except make_pure and make_pure_O so static
checks run once per suite instead of repeating ~291 linter
invocations on every build configuration.
Build performance impact
------------------------
Measured on a 28-thread x86_64 host (clean out-of-tree builds from
identical worktrees, default JEVENTS_ARCH=all):
- Full default build (including shellcheck, mypy, pylint):
* Wall time: 75.98 s -> 65.94 s (-13.2%, -10.04 s)
* CPU time: 472.3 s -> 396.6 s (-16.0%, -75.8 CPU-s)
* Log lines: 2,423 -> 1,165 (-51.9%)
- Full build without linters (NO_SHELLCHECK=1 NO_MYPY=1 NO_PYLINT=1):
* Wall time: 57.83 s -> 44.70 s (-22.7%, -13.13 s)
* CPU time: 222.5 s -> 142.0 s (-36.2%, -80.5 CPU-s)
* Log lines: 2,125 -> 870 (-59.1%)
- Cold libpmu-events.a build: net wall time (excluding feature
detection) drops from 9.22 s to 4.96 s (-46.2%; gross 13.95 s to
8.80 s), COPY rules drop from 1,013 to 0, and build log lines drop
from 1,330 to 60 (-95.5%).
- Metric JSON generation: 136 separate Python processes drop to 3
parallel vendor-scoped invocations (~0.5 s wall time total: 87 ms
AMD, 121 ms ARM64, 503 ms Intel).
- prepare / single-object builds: lib{api,bpf,perf,subcmd,symbol}.a
no longer serialize perf object compilation or pmu-events (saving
~1 s of libperf.a compile latency before pmu-events starts, and
eliminating all 5 archive builds for single-object targets like
perf.o or util/symbol.o).
- build-test (tests/make): a single shellcheck + mypy + pylint pass
(187 shell scripts and 52 Python files, 291 invocations) consumes
~272 CPU-seconds (241 s user + 32 s sys); running it once on
make_pure_O instead of ~42 times across make build-test eliminates
>11,000 CPU-seconds of redundant static analysis.
Tool-generated content disclosure
---------------------------------
Per Documentation/process/coding-assistants.rst and
Documentation/process/generated-content.rst, this series was developed
with AI assistance from Jetski. Across an interactive session guided by
the author, Jetski analyzed the pmu-events and prepare build
dependencies, drafted the Python, Makefile/Build, unit test, commit
message, and cover letter changes, and ran the build and regression
checks listed below.
Testing
-------
Tested on x86_64 Linux (GCC, Clang 21.1.8, bpf-gcc 16.1.0, 28 cores):
- Byte-for-byte comparison of all 137 generated JSONs, pmu-events.c,
pmu-events-string.c, and standalone single-model CLI invocations of
amd_metrics.py, arm64_metrics.py, and intel_metrics.py against
pre-series baselines.
- metric_test.py (8/8 tests including test_MapfileVendorScoping),
mypy-pmu-events, pylint-pmu-events, and
tools/perf/tests/shell/jevents_bad_key.sh.
- Out-of-tree and in-tree builds, incremental no-op rebuilds,
JEVENTS_ARCH={all,x86,arm64,nds32}, NO_JEVENTS=1 (including without
python3 on PATH under NO_JEVENTS=1 NO_LIBBPF=1), NO_LIBBPF=1,
LIBBPF_DYNAMIC=1 (with BPF skeletons), single-object builds (perf.o
and util/symbol.o confirming no .a archives compile during prepare),
clean, and tests/make make_minimal_O (plus command-expansion checks
across tests/make targets).
- scripts/checkpatch.pl across all 8 patches (0 errors; only the
expected "none none" positional args warning in pmu-events/Build).
Not tested:
- Native builds on non-x86 hosts (arm64, riscv, powerpc, s390) and
cross-compilation builds.
- Full end-to-end "make build-test" on this branch (make_gen_vmlinux_h_O
hit an unrelated bpf-gcc 16 C23 error on BTF-generated vmlinux.h,
which is being fixed separately).
- Runtime execution of make_kernelsrc and make_kernelsrc_tools
(verified by expanded command inspection only).
Ian Rogers (8):
perf pmu-events: Ignore backup and non-event JSON files in metric.py
perf jevents: Support --gen-dir/--gen-manifest overlay and ignore
backups
perf build: Avoid copying pmu-events JSON files into OUTPUT
perf pmu-events: Batch metric generation and scope via mapfile.csv
perf build: Batch metric JSON generation in pmu-events/Build
perf build: Run pmu-events tests in parallel with jevents.py
perf build: Depend on lib*-headers instead of archives in prepare
perf tests make: Only run shellcheck, mypy and pylint in pure builds
tools/perf/.gitignore | 7 +-
tools/perf/Makefile.perf | 81 ++++---
tools/perf/bpf_skel.mak | 2 +-
tools/perf/pmu-events/Build | 208 +++++++++---------
tools/perf/pmu-events/amd_metrics.py | 70 +++---
tools/perf/pmu-events/arm64_metrics.py | 45 +++-
tools/perf/pmu-events/intel_metrics.py | 87 +++++---
tools/perf/pmu-events/jevents.py | 290 +++++++++++++++++--------
tools/perf/pmu-events/metric.py | 185 +++++++++++++---
tools/perf/pmu-events/metric_test.py | 65 ++++++
tools/perf/tests/make | 21 +-
11 files changed, 718 insertions(+), 343 deletions(-)
base-commit: 114463420e8acafacaecc4f8caf15d544c3801c8
--
2.56.1.915.g69d5ec7298-goog
next reply other threads:[~2026-12-06 2:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-06 2:11 Ian Rogers [this message]
2026-12-06 2:11 ` [PATCH 1/8] perf pmu-events: Ignore backup and non-event JSON files in metric.py Ian Rogers
2026-12-06 2:22 ` sashiko-bot
2026-12-06 2:11 ` [PATCH 2/8] perf jevents: Support --gen-dir/--gen-manifest overlay and ignore backups Ian Rogers
2026-12-06 2:23 ` sashiko-bot
2026-12-06 2:11 ` [PATCH 3/8] perf build: Avoid copying pmu-events JSON files into OUTPUT Ian Rogers
2026-12-06 2:26 ` sashiko-bot
2026-12-06 2:11 ` [PATCH 4/8] perf pmu-events: Batch metric generation and scope via mapfile.csv Ian Rogers
2026-12-06 2:28 ` sashiko-bot
2026-12-06 2:11 ` [PATCH 5/8] perf build: Batch metric JSON generation in pmu-events/Build Ian Rogers
2026-12-06 2:26 ` sashiko-bot
2026-12-06 2:11 ` [PATCH 6/8] perf build: Run pmu-events tests in parallel with jevents.py Ian Rogers
2026-12-06 2:11 ` [PATCH 7/8] perf build: Depend on lib*-headers instead of archives in prepare Ian Rogers
2026-12-06 2:11 ` [PATCH 8/8] perf tests make: Only run shellcheck, mypy and pylint in pure builds Ian Rogers
2026-12-06 2:22 ` sashiko-bot
2026-12-06 2:28 ` [PATCH 0/8] perf build: Avoid pmu-events copies and improve build parallelism 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=20261206021147.3036701-1-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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