From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796523115; b=5f2U7Yu4WMGVGNEmiBREERgpyfheKm1sMm02AP1fkl5lEs2ewA+8g+u+tqrlU/hcPlkq HsY+WtR7nyZsEKr80eVCxHK0KlCH5a66BGNZOpzut5G5Y7URdXWhIFrAKhGi6cVWg9Rjg WH96UyuvO9nyvyZM0Tk13HQi13bUA80jSrSjKPtEi7fV2uZMWpgyR30OVXYjNDHZFl2Gl 1nAYi+ccPZS8+D+hjM6/CiXJmKGME3ExR2Y51ri9p1xyKwLWCDUvEfzvarQpUGulQpuxa pQ02mN2EixyStma78/6HU3dylQbtHg6lMHvvCQg018FfKFStjzY7Q8uva4D+AFo4xpg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796523115; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=WHAx2SEVcrvbDihny0PHafetUzQPC1h8JCHiGl+CRlU=; b=LdeR3bNLM6SWIMFxbfBqGUIPO5tfFkFip6q91LE1S8lT+kYHpI8Z1Y3+neqJxXzBdcBu AnY3kHd+HNVFDsEEeSqX+qKARjv5t8T9zXhrgiCwQ1RZAcuGaOVhQ3Dxv6ukx2Ydms0Vq KvsboMAw2jlwly9dx3MKINERkO9bZAj5L4EXDwH8mHJ/93vpgfoTbJpFJqzk4a/qZC5e5 U3UhlsoCZLMzp4Sfo6+fQIBzIklbPHzP/TEmT9nVE5MNOqHDS0krvWGPB1u64e9Q+Dw27 HK6fzsYnBY65/85eB//IhLEkSf+trDTJ/zjUZN7aCTAWiKGKtJGiZPSFpDXH2EHprHw== 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=YRQ4Nfb5; arc=none smtp.remote-ip=74.125.82.200 Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) (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 2517E606A335 for ; Sun, 6 Dec 2026 02:11:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2517E606A335 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=YRQ4Nfb5 Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-38355b03cb8so1034507eec.0 for ; Sat, 05 Dec 2026 18:11:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796523113; x=1797127913; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=WHAx2SEVcrvbDihny0PHafetUzQPC1h8JCHiGl+CRlU=; b=YRQ4Nfb5+3v+G51yVTdOhgkRpfLccUyitAF4jhAgZ8YmB0XyfTHflAVeyRjlvkpQuU RrsmRBYFn0jEhfToLMThpR6dYwcTNF9U9hdnEHp77IN2PpJ/cMcK0Bz2tqsXecLZK+Ua cqpHRDfhiJRhaLaBr/AITY20zuu+qh6cDrAR9PJZR18rG/ixbHNpkBK0KXT/tgTsKkya 5lcOj+EVGBaCXLbmwdimc/FgsOvCME8wPalP552+ywU+d7Wl/53FDNH/PfXJUO8yrdWu nspCFzNV3YGqu5YfoXXAqIl19C86EgqlUtxVrgVUEQS8cHofPvysND7BAGazTc1QxI9S /nlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796523113; x=1797127913; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=WHAx2SEVcrvbDihny0PHafetUzQPC1h8JCHiGl+CRlU=; b=nfTQCP4tlFNBvanAMJ4zXwQca1LC0sO/Cdk99TVtCsjqtAyqGmqPu1N/GcZqgVwPI/ GvLGV0elpPSHZPSyAjQfConaisxKMgoXLrlcMn1C4cR2+7QFiAK9jVnHVgJQwGZUForD t2gWdLnptZFGOKl5SWUeUmuFJ9WUw6gyPcwNgTscFvqRuHOvSGEU0FDph4UHuSt4LZJb 2hROITa2XWmKbyG1kceE4P6J+dFKIBkRCvHwOFxH2MCm41z1JB6dlmhpnYkjEvNrORlM mwyjEBtfpS3S8e++piudfAmsnAaZTkGx/w5H48Gthe5RaYkf/9uxy6ctfpUyjAzNdkOv rQ2g== X-Forwarded-Encrypted: i=1; AL+hErE4z3LeAhV5dUvxfV1e08Jcj/v1rRgfnxovKeqksFeXNek2cCzMVArtGcwDdy53sK6BQSzFj0cCAmiuHSY=@vger.kernel.org X-Gm-Message-State: APuU4Z+m9PpsVYN9jaqJP/nuW2tplxp6oGRt0hDLi40pasJ2M20ju157 dcd2lEmopHTLJlVniTsDezlM7TtUAcYbXUOwbR5VFZRHV1PijIapRZoq6lt6hKCZmuumIIi9qAX Cmh4GmYZbtw== X-Received: from dlbvv17.prod.google.com ([2002:a05:7022:5f11:b0:1a7:2bf1:46cc]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:2052:10b0:1b5:cae0:473c with SMTP id a92af1059eb24-1b5d712839fmr6021357c88.33.1796523112858; Sat, 05 Dec 2026 18:11:52 -0800 (PST) Date: Sat, 5 Dec 2026 18:11:39 -0800 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 X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261206021147.3036701-1-irogers@google.com> Subject: [PATCH 0/8] perf build: Avoid pmu-events copies and improve build parallelism From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim 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" 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