mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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>,
	Kan Liang <kan.liang@linux.intel.com>,
	 linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Ian Rogers <irogers@google.com>
Subject: [PATCH 10/10] perf build: Default JEVENTS_ARCH to all
Date: Fri, 13 Nov 2026 13:08:22 -0800	[thread overview]
Message-ID: <20261113210822.3112700-11-irogers@google.com> (raw)
In-Reply-To: <20261113210822.3112700-1-irogers@google.com>

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@google.com>
---
 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


      parent reply	other threads:[~2026-11-13 21:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 21:08 [PATCH 00/10] perf jevents: Block-indexed string compression and default JEVENTS_ARCH=all Ian Rogers
2026-11-13 21:08 ` [PATCH 01/10] perf jevents: Store raw bytes in BigCString instead of C-escaped strings Ian Rogers
2026-11-13 21:08 ` [PATCH 02/10] perf jevents: Sort BigCString entries alphabetically Ian Rogers
2026-11-13 21:08 ` [PATCH 03/10] perf jevents: Store PMU names as string literals in struct pmu_table_entry Ian Rogers
2026-11-13 21:08 ` [PATCH 04/10] perf jevents: Encapsulate big_c_string lookups behind pmu_events__get_string() Ian Rogers
2026-11-13 21:08 ` [PATCH 05/10] perf jevents: Add block-indexed string packing and --compress=zlib Ian Rogers
2026-11-13 21:08 ` [PATCH 06/10] perf jevents: Add --compress=lzma block compression backend Ian Rogers
2026-11-13 21:08 ` [PATCH 07/10] perf jevents: Add --compress=zstd " Ian Rogers
2026-11-13 21:08 ` [PATCH 08/10] perf build: Enable jevents string compression when available Ian Rogers
2026-11-13 21:08 ` [PATCH 09/10] perf tests pmu-events: Test metricgroup descriptions and concurrent lookups Ian Rogers
2026-11-13 21:08 ` Ian Rogers [this message]

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=20261113210822.3112700-11-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=kan.liang@linux.intel.com \
    --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

all inboxes | Powered by JetHome®