From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.197 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796077244; b=k71l6+JyQuTlzxCwrryn0v6i28wH3doBi5iRe1gQDHOSbOG9LKdxKLJQPFXUdI9Z3buo elb+Hh8Lt//rvhtW3hVVGCvU0A81m4wXpN6yn6yLqd56cCuV4WjZxiIdWOUcLMBgbuor6 i0wFZopDLNTzqt46kNE9VxahNrZlCEJ4Rq5h5WO4Ll2jtu6FcB4gpLrX59fMYDa6wxeVv DMg97jPTM+WqVKfXdnECXmuoO2IjDxsCiZyLSLloMvGq7isaot9z8PZLmNIhFfqqU/5rf i69c5NhnOfDT1HcjbHm7eeRLofqe7D4zgFKUZ5y3+DrnkNLcyuI6bPqHaT/Regr5icg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796077244; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=f/PGScdsOH6eLpoPcpS2CVZfkyLym7i4IOerERvxpUE=; b=3z38FyHs/P7Eac7erE1dh6Efb1VR9fugyWzT/Pubr/x3yR6yyJ5aFQVphAIkO5XKUevt j7NruiZZmwQF6ogmONLQE+q0zMS5ZIwuvQKuyMkBI1WEZ1OAdYp0XCORbWMEi7I13GU0l qeWZgdYiDt6Aa59NBeA8fsqD84ghuQXL74XOcn2dgDniBGGdJxf/DTmN0BkaVnjO7xach 3lv8yHMsYjgkqSk/ojHZIY5U59OOGh2Mmak7c9IGiDUwW2otCZ9spiCisaxAvtUyOkc2s nludPQPqYgzzlZ771z6udpLHVsQGl8lc4r2hBM0gvyaf61u8q2G9hrnHT0Q/5Ta6hTg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b="Y7/T5PYu"; arc=none smtp.remote-ip=74.125.82.197 Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E390E606A6A8 for ; Mon, 30 Nov 2026 22:20:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E390E606A6A8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Y7/T5PYu Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-30bcb065bfdso10882752eec.0 for ; Mon, 30 Nov 2026 14:20:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796077243; x=1796682043; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=f/PGScdsOH6eLpoPcpS2CVZfkyLym7i4IOerERvxpUE=; b=Y7/T5PYuAKjPnXgHHb/AlpXxXui1zi9ewRiM8CJAzHEC7zFP5ZUcGxPxDO9a+HofbJ 0xCcteeo8JoUGGaN9L5qtru81UA+6wma3Ph5qcZdVKamO3Fn5DgrjfcOhrZshHeI+uBD mo0d4tXguul8oHTYIJFJc1QfEcXr4uh29LOwaK6wrTfZLOZvWME3IdzGyU/6786UM7fB O1WY62BfRtQewM6BMbe8chG9vMzfTEC7iP1DZc6p++uS/2ufrbbMrZd3axKGthUYpRNE bJVwupgPQUDUJS4i7yyqdbt0zg+yEPwYW+AS+kDZvKw/pDOGrpbEPmbmrJlcQfSNogx8 sECA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796077243; x=1796682043; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=f/PGScdsOH6eLpoPcpS2CVZfkyLym7i4IOerERvxpUE=; b=eSGE/XPAgW6+/NPmGHkPSXBGFwzE5FeFvxXYUX1OgvMhjnq19yfgOiDxMVwpm9bVSn MTj44gMCzQIjqo6o+mnVuCZy06BUk+B2MJPm4nlg1WHVshYl4AfJHCK23aFH/qIjyV7P EyP03WM25Ao3CIf4JmGWNJ2ed3hqY6y9CawopGFhnC9c3LsSyq20x/sRP/7wbAERxdtS rZGQf+jrin1zykCGAokJObklDcoSnLQ8YM08bgGgnXFXSyFkJiddHsatKKpTD+WgHGJ3 taQChDSssOLYCVCOA849CwpRqkAqIFqelZPQ4FavHj0ekLfgiZLUrniEZbmOQBEQMeFY n0Ug== X-Forwarded-Encrypted: i=1; AL+hErHhh4pmox0L8jrMeUfM9uTkxRxX3lLM4NKPynbfQUpUVSLaYWegOud1KPirCBlsiOKtSTIWXOhh9n85E9EYJc4S@vger.kernel.org X-Gm-Message-State: APuU4Z8ggepBG5pfQ698whVrXAbmpsca+VvlXHN++85NRkGAsVHFY7HV dKGFkKMQ+UVERs8r4QRZvPj+6R2wqTaaGFrDoarrzeau2QpCEmMfHJF6CWE/3F02JCJSTOlROPp tdM75Q406dw== X-Received: from dyjk39.prod.google.com ([2002:a05:7300:2727:b0:386:f19c:18bb]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:693c:69dc:b0:386:aff0:6109 with SMTP id 5a478bee46e88-386aff061f8mr25883693eec.2.1796077242591; Mon, 30 Nov 2026 14:20:42 -0800 (PST) Date: Mon, 30 Nov 2026 14:20:08 -0800 In-Reply-To: <20261130222008.4189072-1-irogers@google.com> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261130222008.4189072-1-irogers@google.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261130222008.4189072-12-irogers@google.com> Subject: [PATCH v3 11/11] perf build: Default JEVENTS_ARCH to all From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Athira Rajeev Cc: Jiri Olsa , Adrian Hunter , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Ian Rogers Content-Type: text/plain; charset="UTF-8" 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= (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. Reviewed-by: James Clark Signed-off-by: Ian Rogers --- tools/perf/Makefile.config | 9 +++++++-- tools/perf/Makefile.perf | 3 +++ tools/perf/pmu-events/Build | 2 +- tools/perf/tests/make | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index aed2e952c8f3..4a0012aa88b0 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -928,9 +928,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 8dc67c55020c..012babab64f5 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -133,6 +133,9 @@ include ../scripts/utilities.mak # # Define NO_PYLINT if you do not want to run pylint during build # +# Define JEVENTS_ARCH= to select which architecture(s) PMU event and +# metric tables are generated for (defaults to all). +# # Define JEVENTS_COMPRESS= 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 c38eb8909b84..491a0813b630 100644 --- a/tools/perf/tests/make +++ b/tools/perf/tests/make @@ -78,7 +78,7 @@ make_clang := CC=clang 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_bpf_skel_clang := CLANG=$(CLANG) BPF_GCC= @@ -209,7 +209,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 ifeq ($(have_clang_bpf),1) -- 2.56.1.839.g22a8290db9-goog