[PATCH 10/10] perf build: Default JEVENTS_ARCH to all

From: Ian Rogers

Date: Fri Nov 13 2026 - 17:11:59 EST


Because block-indexed string compression packs PMU event and metric
strings into independently compressed ~8 KiB blocks decompressed on
demand via (block_id << 16) | sub_offset, bundling non-host
architectures' compressed blocks in .rodata incurs zero runtime
decompression CPU or heap memory unless those architectures are queried.
With zstd enabled, bundling PMU event and metric tables for all
architectures (JEVENTS_ARCH=all) is 5.77 MiB smaller overall than an
uncompressed x86-only build (JEVENTS_ARCH=x86 JEVENTS_COMPRESS=none),
cutting the stripped perf binary nearly in half (-45.4%) while enabling
cross-architecture perf.data analysis out of the box:

Component x86 + none all + zstd Delta
-----------------------------------------------------------------
pmu-events-string.o (dec) 6,901,987 B 794,032 B -88.5%
pmu-events.o (dec) 257,987 B 314,940 B +22.1%
pmu-events-in.o (dec) 7,160,005 B 1,109,002 B -84.5%
perf stripped (file size) 13,321,832 B 7,276,200 B -45.4%
perf unstripped (file) 24,526,816 B 18,494,088 B -24.6%

Adding every non-x86 architecture (arm64, powerpc, riscv, s390, nds32)
only adds +55.6 KiB of compact tables in pmu-events.o and +194.6 KiB of
compressed string blocks in pmu-events-string.o (785,912 B .text for all
vs 586,654 B for x86).

Runtime decompression overhead is minimal. Measured on a hybrid Intel
Core i7-14700 (cpu_core + cpu_atom) across 100 interleaved rounds of
'perf stat true' (which parses default events and Default/TopdownL1
metrics across both core PMUs plus common):

Build mode Wall med Delta wall User med Sys med MinFlt
-----------------------------------------------------------------
none (x86) 27.10 ms -- 12.01 ms 16.52 ms 4,036
zstd (x86) 29.93 ms +2.83 ms 12.65 ms 17.92 ms 4,583
zlib (x86) 31.13 ms +4.03 ms 13.96 ms 17.65 ms 4,548
lzma (x86) 35.05 ms +7.95 ms 19.25 ms 17.87 ms 4,555
all + zstd 30.25 ms +3.15 ms 14.05 ms 18.04 ms 4,652

Where the ~2.8-3.1 ms in 'perf stat true' (zstd) goes:
1. Pure decompression CPU (+0.64 ms user time on x86, +2.04 ms on all):
Digesting the 64 KiB ZSTD_DDict once and decompressing the touched
8 KiB blocks takes ~640 us in user space on x86 (compared to +1.95 ms
with zlib and +7.24 ms with lzma).
2. Anonymous heap page faults (~1.4 ms sys time, +547 to +616 minor
faults): In a warm-cache benchmark, uncompressed mode faults
pre-populated page-cache pages from .rodata, whereas compressed mode
allocates malloc() buffers (~2.1 MiB across ~265 decompressed 8 KiB
blocks), incurring kernel zero-page minor faults. On a cold-disk
invocation, reading ~6 MB less .rodata from disk offsets this.
3. Why ~265 blocks are touched on 'perf stat true': Resolving Default
metricgroups (TopdownL1, Default2, Default3, Default4) calls
pmu_metrics_table__for_each_metric() across both cpu_core and
cpu_atom (alderlake) plus common, linearly scanning every metric in
those tables (~190 metric blocks) before binary-searching the ~30
referenced events (~75 event blocks).

On 'perf list' (100 interleaved rounds), user CPU time only increases
from 32.10 ms (none) to 34.09 ms (zstd, +2.00 ms) and is unchanged at
32.08 ms for all+zstd, negligible next to the ~850 ms spent scanning
sysfs PMUs and tracepoints.

Default JEVENTS_ARCH to all in Makefile.config and pmu-events/Build,
allow single-architecture builds via JEVENTS_ARCH=<arch> (falling back
to NO_JEVENTS=1 if that architecture lacks mapfile.csv), and update
tools/perf/tests/make to exercise JEVENTS_ARCH=$(SRCARCH) alongside the
new default.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/Makefile.config | 9 +++++++--
tools/perf/Makefile.perf | 3 +++
tools/perf/pmu-events/Build | 2 +-
tools/perf/tests/make | 3 ++-
4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index b4764f69f47f..6051d7c7dee8 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -872,9 +872,14 @@ else
endif
endif

+ifeq ($(JEVENTS_ARCH),)
+ JEVENTS_ARCH := all
+endif
ifneq ($(NO_JEVENTS),1)
- ifeq ($(wildcard pmu-events/arch/$(SRCARCH)/mapfile.csv),)
- NO_JEVENTS := 1
+ ifneq ($(JEVENTS_ARCH),all)
+ ifeq ($(wildcard pmu-events/arch/$(JEVENTS_ARCH)/mapfile.csv),)
+ NO_JEVENTS := 1
+ endif
endif
endif
ifneq ($(NO_JEVENTS),1)
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 53ab82681569..e9b8945b5622 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -130,6 +130,9 @@ include ../scripts/utilities.mak
#
# Define NO_PYLINT if you do not want to run pylint during build
#
+# Define JEVENTS_ARCH=<arch|all> to select which architecture(s) PMU event and
+# metric tables are generated for (defaults to all).
+#
# Define JEVENTS_COMPRESS=<zstd|zlib|lzma|none> to select or disable
# block-indexed compression of generated PMU event and metric strings, where
# strings are packed into ~8 KiB blocks compressed independently and
diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build
index 88b6b47951e0..32fc1378ef3a 100644
--- a/tools/perf/pmu-events/Build
+++ b/tools/perf/pmu-events/Build
@@ -36,7 +36,7 @@ else

# Setup the JEVENTS_ARCH, JEVENTS_MODEL and JEVENTS_COMPRESS
ifeq ($(JEVENTS_ARCH),)
-JEVENTS_ARCH=$(SRCARCH)
+JEVENTS_ARCH=all
endif
ifeq ($(JEVENTS_MODEL),)
JEVENTS_MODEL=all
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 5a04f67257ac..b69ddc9e1489 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -77,6 +77,7 @@ make_clang_nondistro := CC=clang BUILD_NONDISTRO=1
make_extra_tests := EXTRA_TESTS=1
make_no_jevents := NO_JEVENTS=1
make_jevents_all := JEVENTS_ARCH=all
+make_jevents_arch := JEVENTS_ARCH=$(SRCARCH)
make_jevents_compress_none := JEVENTS_COMPRESS=none
make_no_bpf_skel := BUILD_BPF_SKEL=0
make_gen_vmlinux_h := GEN_VMLINUX_H=1
@@ -172,7 +173,7 @@ endif
endif
run += make_extra_tests
run += make_no_jevents
-run += make_jevents_all
+run += make_jevents_arch
run += make_jevents_compress_none
run += make_no_bpf_skel
run += make_gen_vmlinux_h
--
2.56.1.703.gf848ed807c-goog