From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796133726; b=VCawoW1wVSxl1D20vT3ZFaW6BPd/DUjSkIpCOrJjtsUT1ZdcoPp9O2U1NGARfArpdb0K V8UWgpxGXMdedrMdN22jM47gu6wCRQZlA8Bup5ieKRpedT92D/2C04rC9hsWpEq/Xtk26 UXwVtR9pZZ1mdeOsf2YQnrKADHqExHdAlUh99FrYCT6x2x+dPSy9cN/j3+4USy3nnD/bF HsJ9OokXOvM3K/FP2o/h/sC32YTc10YceOW4sMJ7aSGTggr8IO2xmCIaTwSlSlLI0NZIY PnSr1sW8y0Fh6CbYChYHsEWL5F5bjA0AQSSIqds1u+2o+bSa8yLRbIW372HXFDehPaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796133726; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:Content-Type:Mime-Version:Subject: From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id: References:To:X-Mailer:X-TM-AS-GCONF:X-Proofpoint-Reinject: X-Proofpoint-ORIG-GUID:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-GUID:X-Proofpoint-Spam-Info:X-Authority-Analysis: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=i2yoOwveCm076pgFEl4mfUhvuuXxywQBMu8mheCgM/0=; b=YHjhvFti4iTK/KeVJ0Qo5dY9caPXjY4zN7LJK/Iwe1cQN2/6BCHxV4y2wlGWCzimXQsR 2LfpxJLM12WoreS4Hx6kxKtFP/c4EssgK50bkJ8Q935MeR/VOXjLLVEiaRHoXGRoa1Uge iUsUUnB8izc0pD9/gDIIak8s+/+NlKejRb+fDsXmFfJ75lLJ1X9QSX/SxWDyIIREnmOxc TZ1/s8nLzSb+ce3pcWfnegMLpSXFPHdfEPVLsAmpzCjD1bfY+r2Y1j2x3CF2YMAwI7HQw DSBeJUsW6yy81u0GipJ1pf7pZWTluhLh69kweXF2KcC2eOMgwX2aAjJEvvJqfLamFBg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=ETHacjbb; arc=none smtp.remote-ip=148.163.156.1 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6ECE7606A329; Tue, 1 Dec 2026 14:02:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6ECE7606A329 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=ETHacjbb Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1D4YtN247332; Tue, 1 Dec 2026 14:01:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=i2yoOw veCm076pgFEl4mfUhvuuXxywQBMu8mheCgM/0=; b=ETHacjbbwXBOp/pZCqLiT5 nZb6nAbxJT6ENGe9WvkzukrQxLq4FJoTRpC3eKiUcbUJRyl6f9CbjWpdQFfuKrVA nRfGpaTXnL8uSnevDXFEQLNAZiFPJc1NxZ7ESXUYgWTi8Ah9y+q04Hz4IBS3uovX mJXo5QjSma1tks5WrKXvNG8h8BzgWSjxo+qVeYavgO+wSItOaslWWSf+WZ0pP9gK I0rgKP3dpwSr4V2FEpHJuG4oxWhbx07n7YTq5TjN6nECjtDG9c7F+62qjUc+eFuy pb2piMFTsO9MuPUiPzp+QzPuWribR2gFerDxHcExI8QauGTz0OyJ2iMkRXXxDnNA == Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pmt4y01-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 14:01:47 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1D4GrW2692380; Tue, 1 Dec 2026 14:01:46 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4j8asgsbpn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 14:01:46 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B1E1i2e49938792 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 Dec 2026 14:01:44 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A71D920086; Tue, 1 Dec 2026 14:01:44 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EDDE62004E; Tue, 1 Dec 2026 14:01:41 +0000 (GMT) Received: from smtpclient.apple (unknown [9.39.18.191]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTPS; Tue, 1 Dec 2026 14:01:41 +0000 (GMT) Content-Type: text/plain; charset=utf-8 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.300.41.1.7\)) Subject: Re: [PATCH v3 00/11] perf jevents: Block-indexed string compression and default JEVENTS_ARCH=all From: Athira Rajeev In-Reply-To: <20261130222008.4189072-1-irogers@google.com> Date: Tue, 1 Dec 2026 19:31:29 +0530 Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Adrian Hunter , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20261130222008.4189072-1-irogers@google.com> To: Ian Rogers X-Mailer: Apple Mail (2.3864.300.41.1.7) X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-ORIG-GUID: 6zjSe4txi4Ns6-pE_wPtV7wqdl-M6g2w X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA1NCBTYWx0ZWRfXw0WGmD496FSj 6SrqThrS2eOuUEZggrXJe+TgeaIaVXCpmwbkYmiXQMofmHLei5TaMD86m4SnsEEtwlibN9G/c+t yEhy7QDlSpjm5Lk8YYgg2hd0FZBIXrJVHPiW5vUMsPEGj1LCL8YPF2k1XDBjTe7Qaz5RFUNPcU+ jAjMgvoLpLUDOu9S85nq2UbgTjRISFIR+aB6+nJ27TgCoP8RxfzTwp5nz2hT5YvxyHciHfBwMQe 14NMGS498TvYYDyXb6h6TOuqVC8UuXhJrcuVnRGEU9q6zrolOQNja6JT0/YlMITPv5P3YXkGNCM bq+SkMKpPX4UIIPfSOoQtoHm6RGLfmYcgoYj0WfucrROLGVpdu1dnT8NOFGHowXKrtIC3f1kGM+ zS5uEcR8OWy7xAoanhtGFDBGLZCM6DP+i/TRbGlVsNi78ZqdvUj1PO/hWppqKEugtLhIq2XABwo c0CB3H1pNhAxmwOFJmQ== X-Proofpoint-GUID: 0XXB1It9AzmxYmBcz1GySdAbpoipQtBY X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA1NCBTYWx0ZWRfX8CYZGz7q+vhx WBKGB38yVzuliN81kcYauD7vrMp0OuJ28M/QeztsDue0KjkibCR+8f1gYmQv1em3g9L0jWDR72u Xv6gxDQqFBkdgnfNDwZZUtq1Yvka5p4= X-Authority-Analysis: v=2.4 cv=U9cHnuru c=1 sm=1 tr=0 ts=6b0ed34c cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VwQbUJbxAAAA:8 a=1XWaLZrsAAAA:8 a=VnNF1IyMAAAA:8 a=9q5QzyoYyRX5csUzuLkA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_02,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010054 > On 1 Dec 2026, at 3:49=E2=80=AFAM, Ian Rogers = wrote: >=20 > Compiled-in PMU event and metric tables (pmu-events-in.o) currently > store ~6.9 MiB of uncompressed string data in .rodata on x86 alone, > causing JEVENTS_ARCH to default to $(SRCARCH) rather than all and > preventing out-of-the-box cross-architecture perf.data event/metric > resolution unless explicitly built with JEVENTS_ARCH=3Dall. >=20 > Compressing big_c_string as a single whole-table stream would force = perf > to allocate and decompress megabytes of unused CPU models' strings on > startup just to resolve a single event, whereas compressing individual > short strings suffers from poor compression ratios and per-string > framing overhead. >=20 > Instead, this series introduces "block-indexed string compression": > sorted, suffix-folded event and metric byte records are packed into > ~8 KiB blocks without splitting records across block boundaries, each > block is compressed independently (sharing a single preset or trained > dictionary across blocks so ~8 KiB blocks retain high compression > ratios), and every uint32_t string offset is encoded as > (block_id << 16) | sub_offset. An ~8 KiB target block size sits at the > knee of the compression vs. random-access curve (smaller 1-4 KiB = blocks > pay 22-128% more .rodata for per-block entropy headers and index > entries, while larger 16-64 KiB blocks yield <15% extra savings at = 2-8x > higher decompression and page-fault cost per binary-search probe). At > runtime, pmu_events__get_string() uses a lock-free atomic block = pointer > cache to decompress only the touched ~8 KiB blocks on demand, leaving > untouched CPU models' and non-host architectures' blocks compressed in > .rodata at zero runtime CPU or heap cost. >=20 > The series starts with a standalone BigCString raw-byte fix for > describe_metricgroup() binary-search ordering, prepares the string and > PMU table layout, adds the zlib, lzma, and zstd block compression > backends, scopes metricgroup descriptions per struct pmu_metrics_table > so JEVENTS_ARCH=3Dall never leaks descriptions across architectures or > models, and switches the default JEVENTS_ARCH to all: Hi Ian, Thanks for the V3. Tried the V3 series on powerpc ( ppc64le ) and there is no metric = description issues observed. Series looks good to me. Tested-by: Athira Rajeev Thanks Athira >=20 > - Bug fix, string layout, and hot-path isolation (Patches 1-4): > - Patch 1 stores raw NUL-delimited UTF-8 bytes in BigCString instead > of C-escaped strings, fixing suffix folding and = describe_metricgroup() > binary-search ordering on prefix-overlapping names (such as "Bad" = vs > "BadSpec"; Fixes: 66c6e0c10027) without changing empty-pmu-events.c > so it can be cherry-picked standalone. > - Patch 2 partitions non-folded BigCString event strings before = metric > strings and sorts entries lexicographically by their raw UTF-8 byte > sequence within each partition so identically prefixed event names, > encodings, descriptions, and metric expressions cluster into > adjacent ~8 KiB blocks, improving block compression ratios by > ~20-23%. > - Patch 3 stores PMU names directly as const char *pmu_name string > literals in struct pmu_table_entry (only 68 unique PMU names / 536 = B > across ~443 rows across all architectures, already in .data.rel.ro) > so the compiler/linker merge them in .rodata.str1.1 and hot PMU > wildcard scans never touch big_c_string or trigger block > decompression. > - Patch 4 encapsulates big_c_string offset lookups behind > pmu_events__get_string(uint32_t offset) across pmu-events.c and > pmu-events-string.c. > - On-demand block decompression backends (Patches 5-8): > - Patch 5 packs big_c_string into ~8 KiB record-aligned blocks = indexed > by (block_id << 16) | sub_offset, adds lock-free thread-safe atomic > per-block decompression on demand, and adds --compress=3Dzlib using > raw Deflate with a <=3D 32 KiB preset dictionary. > - Patch 6 adds --compress=3Dlzma using raw LZMA2 per block with a 64 = KiB > dictionary window. > - Patch 7 adds --compress=3Dzstd using ZSTD_decompress_usingDDict() = per > block with a once-digested shared 64 KiB ZSTD_DDict (~26% smaller > .rodata than dictionary-free ~8 KiB zstd blocks). > - Patch 8 wires JEVENTS_COMPRESS into Makefile.perf and > pmu-events/Build, preferring zstd, then zlib, then lzma, and = falling > back to none. > - Scoped metricgroups, testing, and JEVENTS_ARCH=3Dall default = (Patches 9-11): > - Patch 9 scopes metricgroup descriptions to each struct > pmu_metrics_table (deduplicating identical arrays across models = into > 31 tables across all architectures), exposes > pmu_metrics_table__describe_metricgroup(), and restricts > describe_metricgroup() to pmu_metrics_table__find() and > pmu_metrics_table__default() so JEVENTS_ARCH=3Dall never leaks x86 > descriptions (e.g. Memory_BW) onto PowerPC or lets Intel/AMD > lpm_cpu_power descriptions overwrite each other. > - Patch 10 adds prefix-overlapping metricgroups.json test coverage, > cross-architecture and cross-model isolation assertions (power10 > Memory_BW, skylake vs amdzen4 lpm_cpu_power), and an 8-thread > concurrent event/metric/metricgroup stress test in perf test > pmu-events. > - Patch 11 switches the default JEVENTS_ARCH to all. Bundling all > architectures (x86, arm64, powerpc, riscv, s390, nds32) with zstd > shrinks pmu-events-in.o from 7.16 MiB (x86 + none) to 1.10 MiB > (all + zstd, -84.6%) and cuts the stripped perf binary nearly in > half, with ~3 ms median wall-clock overhead on 'perf stat true'. >=20 > v3: > - New Patch 9: Scope metricgroup descriptions per struct > pmu_metrics_table and add pmu_metrics_table__describe_metricgroup() = so > JEVENTS_ARCH=3Dall does not leak x86's Memory_BW description onto > PowerPC or clobber AMD/Intel lpm_cpu_power descriptions (reported by > Athira Rajeev). > - Patch 10 (was Patch 9): Update test__metricgroups() to exercise > pmu_metrics_table__describe_metricgroup() and verify cross-arch > (power10 Memory_BW) and cross-model (skylake vs amdzen4 = lpm_cpu_power) > isolation. > - Rebase onto latest tmp.perf-tools-next (resolving the = tools/perf/tests/make > conflict noted by Athira Rajeev) and add James Clark's Reviewed-by on > unchanged patches. > - v2: = https://lore.kernel.org/linux-perf-users/20261116070038.2968725-1-irogers@= google.com/ >=20 > v2: > - Patch 1: Avoid rebinding pmu_name from str to bytes in > print_pending_events() and print_pending_metrics() (use > pmu_name_bytes) and annotate _args as Optional[argparse.Namespace] so > mypy type-checks functions guarding on 'assert _args is not None' > (Sashiko). > - Patch 10 (now Patch 11): Remove the unreferenced make_jevents_all > definition in tools/perf/tests/make (Sashiko). > - Rebase onto latest perf-tools-next. > - v1: = https://lore.kernel.org/linux-perf-users/20261113210822.3112700-1-irogers@= google.com/ >=20 > AI Assistance Disclosure (per = Documentation/process/coding-assistants.rst > and Documentation/process/generated-content.rst): > - Tools used: Antigravity coding assistant and Sashiko automated patch > review. > - Summary of prompts and assistance: Interactive design and > implementation of the BigCString raw-byte fix and alphabetical > sorting, struct pmu_table_entry PMU name string literals, lock-free > 8 KiB block-indexed decompression across zlib, lzma, and zstd, > per-table metricgroup description scoping, Makefile.config/Build > integration, multithreaded unit tests, size/latency benchmarking, and > review fixes. > - Testing performed: Built and tested GCC (MYPY=3D1 PYLINT=3D1), = CC=3Dclang, > JEVENTS_COMPRESS=3D{none,zlib,lzma,zstd}, NO_JEVENTS=3D1, > JEVENTS_ARCH=3D{x86,all}, AddressSanitizer + LeakSanitizer, perf test > (pmu-events, metric parsing), and scripts/checkpatch.pl. >=20 > Ian Rogers (11): > perf jevents: Store raw bytes in BigCString instead of C-escaped > strings > perf jevents: Sort BigCString entries alphabetically > perf jevents: Store PMU names as string literals in struct > pmu_table_entry > perf jevents: Encapsulate big_c_string lookups behind > pmu_events__get_string() > perf jevents: Add block-indexed string packing and --compress=3Dzlib > perf jevents: Add --compress=3Dlzma block compression backend > perf jevents: Add --compress=3Dzstd block compression backend > perf build: Enable jevents string compression when available > perf jevents: Scope metricgroup descriptions to struct > pmu_metrics_table > perf tests pmu-events: Test metricgroup descriptions and concurrent > lookups > perf build: Default JEVENTS_ARCH to all >=20 > tools/perf/.gitignore | 1 + > tools/perf/Makefile.config | 9 +- > tools/perf/Makefile.perf | 13 +- > tools/perf/pmu-events/Build | 49 +- > .../arch/test/test_soc/cpu/metricgroups.json | 4 + > tools/perf/pmu-events/empty-pmu-events.c | 7844 +++++++++-------- > tools/perf/pmu-events/jevents.py | 1106 ++- > tools/perf/pmu-events/pmu-events.h | 2 + > tools/perf/tests/make | 6 +- > tools/perf/tests/pmu-events.c | 284 +- > 10 files changed, 5229 insertions(+), 4089 deletions(-) > create mode 100644 = tools/perf/pmu-events/arch/test/test_soc/cpu/metricgroups.json >=20 >=20 > base-commit: 4a7008f739a30ee4c22d9f21af362a5128f2628d > --=20 > 2.56.1.839.g22a8290db9-goog >=20