* [PATCH v1 00/14] perf build: Reduce build time by one third
@ 2026-05-12 5:35 Ian Rogers
2026-05-12 5:35 ` [PATCH v1 01/14] bpftool build: Restrict feature tests during bootstrap compilation Ian Rogers
` (14 more replies)
0 siblings, 15 replies; 36+ messages in thread
From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw)
To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko,
Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter,
James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor,
Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre,
Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk,
Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon,
Ricky Ringler, linux-kernel, bpf, linux-perf-users
Cc: Ian Rogers
This patch series refactors many aspects of the perf build aiming to
better encapsulate BPF code generation, remove serial build code and
gain build parallelism. The prepare step that blocks the parallel
build is reduced to a core 6 smaller dependencies. BPF skeletons are
made regular dependencies on the targets that use them. Feature tests
and dependencies are reorgnized. The jevents.py script processes json
files in parallel and allows the big_c_string to be compiled
separately.
On a 28-core build workstation (make -j28 all from scratch), clean build
latency improves by over 36%:
Before:
real 0m29.006s
user 2m46.019s
sys 0m30.610s
After:
real 0m18.498s
user 2m32.922s
sys 0m27.623s
Summary of Patches:
1: bpftool Bootstrap Optimization
- Exempts bpftool bootstrap from non-essential feature tests (LLVM, libbfd,
libcap), saving 1.1s of sub-make fork overhead during Kbuild startup.
2-4: Flattening Umbrella Prepare Barriers
- builtin-trace embedded inclusions and pmu-events generation are completely
decoupled from the sequential "prepare" umbrella target, eliminating Make
AST double-parsing overhead and unchoking parallel compilation barriers.
5-8: Decoupling & Pre-generating BPF Skeletons
- BPF skeleton rules are extracted out of Makefile.perf into bpf_skel.mak.
- Decouples bpftool bootstrap from top-level static libbpf dependencies,
attaching bpf-skel-prepare directly to the umbrella prepare target. This
allows Make to pre-compile bpftool and dump vmlinux.h in the background at
build startup, removing the 7-second serialization bottleneck before BPF
object compilation.
9-11: Foundational Linkage & Fast-Path Feature Detection
- Eliminates redundant libbpf sub-make feature checks during static builds.
- Integrates libdebuginfod directly into test-all.c, allowing Make to skip
individual feature check sub-make forks during AST parsing on fully
configured workstations.
12-13: jevents.py Concurrency & Deduplication
- Splits the massive 2.8 MB big_c_string literal out of pmu-events.c into a
dedicated pmu-events-string.c compilation unit. This slices C compilation
latency in half by compiling string and struct tables simultaneously across
separate CPU cores while preserving zero dynamic ELF relocations.
- Pre-populates jevents.py JSON ASTs and metric formulas in parallel across
all available CPU cores using ProcessPoolExecutor (accelerating Python
execution by 11x, from 3.3s down to ~290ms).
14: Out-of-Tree Incremental Rebuild Fix
- Prefixes SCRIPTS (perf-archive, perf-iostat) with $(OUTPUT) to prevent
Make from continuously re-executing script installation rules on already
built out-of-tree builds.
Ian Rogers (14):
bpftool build: Restrict feature tests during bootstrap compilation
perf trace beauty: Make beauty generated C code standalone .o files
perf build: Decouple pmu-events from prepare umbrella target
perf build: Remove empty archheaders target
perf build: Move BPF skeleton generation out of Makefile.perf
perf build: Encapsulate vmlinux.h and bpftool in bpf_skel.mak
perf build: Move static libbpf dependency out of prepare step
perf build: Pre-generate BPF skeletons during umbrella prepare phase
perf build: Move libsymbol dependency out of prepare step
perf build: Remove redundant libbpf feature check for static builds
tools build: Integrate libdebuginfod into test-all fast path
perf pmu-events: Split big_c_string storage into standalone
compilation unit
perf pmu-events: Parallelize JSON and metric pre-computation in
jevents.py
perf build: Prefix SCRIPTS with output directory to fix continuous
rebuilds
tools/bpf/bpftool/Makefile | 5 +
tools/build/Makefile.feature | 6 +-
tools/build/feature/Makefile | 2 +-
tools/build/feature/test-all.c | 5 +
tools/perf/Build | 2 +
tools/perf/Makefile.config | 6 +-
tools/perf/Makefile.perf | 427 +-----------------
tools/perf/bench/Build | 6 +
.../bpf_skel/bench_uprobe.bpf.c | 0
tools/perf/bench/uprobe.c | 2 +-
tools/perf/bpf_skel.mak | 110 +++++
tools/perf/builtin-trace.c | 30 +-
tools/perf/pmu-events/Build | 15 +-
tools/perf/pmu-events/jevents.py | 56 ++-
tools/perf/trace/beauty/Build | 280 ++++++++++++
tools/perf/trace/beauty/arch_errno_names.c | 2 +
tools/perf/trace/beauty/arch_errno_names.sh | 2 +-
tools/perf/trace/beauty/beauty.h | 60 +++
tools/perf/trace/beauty/eventfd.c | 6 +-
tools/perf/trace/beauty/fsconfig.c | 5 +
tools/perf/trace/beauty/futex_op.c | 6 +-
tools/perf/trace/beauty/futex_val3.c | 6 +-
tools/perf/trace/beauty/mmap.c | 24 +-
tools/perf/trace/beauty/mode_t.c | 6 +-
tools/perf/trace/beauty/msg_flags.c | 8 +-
tools/perf/trace/beauty/open_flags.c | 1 +
tools/perf/trace/beauty/perf_event_open.c | 22 +-
tools/perf/trace/beauty/pid.c | 5 +-
tools/perf/trace/beauty/sched_policy.c | 8 +-
tools/perf/trace/beauty/seccomp.c | 12 +-
tools/perf/trace/beauty/signum.c | 6 +-
tools/perf/trace/beauty/socket_type.c | 6 +-
.../perf/{util => trace/beauty}/syscalltbl.c | 0
.../perf/{util => trace/beauty}/syscalltbl.h | 0
tools/perf/trace/beauty/tracepoints/Build | 22 +
tools/perf/trace/beauty/waitid_options.c | 8 +-
tools/perf/util/Build | 17 +-
tools/perf/util/bpf-trace-summary.c | 2 +-
tools/perf/util/env.c | 4 +-
tools/perf/util/env.h | 1 +
40 files changed, 700 insertions(+), 491 deletions(-)
rename tools/perf/{util => bench}/bpf_skel/bench_uprobe.bpf.c (100%)
create mode 100644 tools/perf/bpf_skel.mak
create mode 100644 tools/perf/trace/beauty/fsconfig.c
rename tools/perf/{util => trace/beauty}/syscalltbl.c (100%)
rename tools/perf/{util => trace/beauty}/syscalltbl.h (100%)
--
2.54.0.563.g4f69b47b94-goog
^ permalink raw reply [flat|nested] 36+ messages in thread* [PATCH v1 01/14] bpftool build: Restrict feature tests during bootstrap compilation 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-12 5:35 ` [PATCH v1 02/14] perf trace beauty: Make beauty generated C code standalone .o files Ian Rogers ` (13 subsequent siblings) 14 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers When bpf_skel.mak executes 'make -C ../bpf/bpftool bootstrap', bpftool's Makefile unconditionally evaluated feature checks for llvm, libcap, libbfd, and disassembler libraries because the bootstrap target was not exempted. Since the bootstrap bpftool strictly compiles minimal AST parsing and C code generation logic without linking LLVM or disassembler libraries, these feature check sub-makes are completely redundant. Exempt the bootstrap target from non-essential feature tests to eliminate unneeded sub-make fork overhead during Kbuild startup. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/bpf/bpftool/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 0febf60e1b64..8f50bc163bb2 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -106,6 +106,10 @@ ifneq ($(SKIP_CRYPTO),1) CRYPTO_LIBS := -lcrypto endif +ifeq ($(MAKECMDGOALS),bootstrap) +FEATURE_TESTS := libelf-zstd +FEATURE_DISPLAY := +else FEATURE_TESTS := clang-bpf-co-re FEATURE_TESTS += llvm FEATURE_TESTS += libcap @@ -122,6 +126,7 @@ FEATURE_DISPLAY += libcap FEATURE_DISPLAY += libbfd FEATURE_DISPLAY += libbfd-liberty FEATURE_DISPLAY += libbfd-liberty-z +endif check_feat := 1 NON_CHECK_FEAT_TARGETS := clean uninstall doc doc-clean doc-install doc-uninstall -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v1 02/14] perf trace beauty: Make beauty generated C code standalone .o files 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers 2026-05-12 5:35 ` [PATCH v1 01/14] bpftool build: Restrict feature tests during bootstrap compilation Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-13 5:21 ` sashiko-bot 2026-05-12 5:35 ` [PATCH v1 03/14] perf build: Decouple pmu-events from prepare umbrella target Ian Rogers ` (12 subsequent siblings) 14 siblings, 1 reply; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers Previously, builtin-trace.c directly included 15 embedded C files (e.g. trace/beauty/mmap.c and fsconfig_arrays.c), which in turn depend on dozens of generated beauty script arrays. To satisfy these embedded inclusions, the global Makefile.perf would define all the generator variables/rules and include them in the massive sequential prepare umbrella target, choking parallel build startup. Furthermore, tools/perf/util/syscalltbl.c included its own generated mapper, and util/env.c conditionally included arch_errno_names.c inline, splitting consumers across directories and preventing clean Make encapsulation. Refactor the framework to achieve better encapsulation: 1. Move util/syscalltbl.[ch] into trace/beauty/ to co-locate with all generated code consumers. 2. Create fsconfig.c and flatten embedded beauty .c files to compile as independent standalone objects via trace/beauty/Build, exporting their formatting functions via beauty.h and env.h. Switch arch_errno_names.o and syscalltbl.o assignments directly to perf-util-y and add a top-level recursive kbuild hook (perf-util-$(CONFIG_TRACE) += trace/beauty/) to compile them into libperf-util.a, resolving remote linkage for standalone python extensions. 3. Bridge private opaque references (struct trace) securely via accessors trace__show_zeros() and trace__host(), avoiding header entanglements. 4. Consolidate all generator variables, script paths, and array generation rules entirely out of Makefile.perf and place them directly inside the exact local Build files where their output objects are compiled (trace/beauty/Build and trace/beauty/tracepoints/Build), binding prerequisites locally. Use $(call rule_mkdir) directly inside generator recipes to guarantee dynamic directory creation before script redirection, and append $(call echo-cmd,gen) across all rules to print clean, standardized GEN ... file.c output during compilation. 5. Clean up clean target to recursively remove the generated directory instead of relying on dozens of individual variables. This unchokes the "prepare" target parallel barrier, allows make to evaluate generation scripts purely locally where consumed, and flattens the tracepoint formatting architecture. Testing a parallel build (make -j28 all from scratch) shows improvements: Before: real 0m28.689s user 2m38.490s sys 0m30.148s After: real 0m27.642s user 2m32.356s sys 0m26.683s So reclaiming ~9.6 seconds of raw CPU time and over 1 full second off overall real-world build latency, by overlapping sub-make startup and avoiding top-level double-parsing overhead. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Build | 2 + tools/perf/Makefile.perf | 282 +----------------- tools/perf/builtin-trace.c | 30 +- tools/perf/trace/beauty/Build | 280 +++++++++++++++++ tools/perf/trace/beauty/arch_errno_names.c | 2 + tools/perf/trace/beauty/arch_errno_names.sh | 2 +- tools/perf/trace/beauty/beauty.h | 60 ++++ tools/perf/trace/beauty/eventfd.c | 6 +- tools/perf/trace/beauty/fsconfig.c | 5 + tools/perf/trace/beauty/futex_op.c | 6 +- tools/perf/trace/beauty/futex_val3.c | 6 +- tools/perf/trace/beauty/mmap.c | 24 +- tools/perf/trace/beauty/mode_t.c | 6 +- tools/perf/trace/beauty/msg_flags.c | 8 +- tools/perf/trace/beauty/open_flags.c | 1 + tools/perf/trace/beauty/perf_event_open.c | 22 +- tools/perf/trace/beauty/pid.c | 5 +- tools/perf/trace/beauty/sched_policy.c | 8 +- tools/perf/trace/beauty/seccomp.c | 12 +- tools/perf/trace/beauty/signum.c | 6 +- tools/perf/trace/beauty/socket_type.c | 6 +- .../perf/{util => trace/beauty}/syscalltbl.c | 0 .../perf/{util => trace/beauty}/syscalltbl.h | 0 tools/perf/trace/beauty/tracepoints/Build | 22 ++ tools/perf/trace/beauty/waitid_options.c | 8 +- tools/perf/util/Build | 4 +- tools/perf/util/bpf-trace-summary.c | 2 +- tools/perf/util/env.c | 4 +- tools/perf/util/env.h | 1 + 29 files changed, 468 insertions(+), 352 deletions(-) create mode 100644 tools/perf/trace/beauty/fsconfig.c rename tools/perf/{util => trace/beauty}/syscalltbl.c (100%) rename tools/perf/{util => trace/beauty}/syscalltbl.h (100%) diff --git a/tools/perf/Build b/tools/perf/Build index b03cc59dabf8..e18c80a5c1bc 100644 --- a/tools/perf/Build +++ b/tools/perf/Build @@ -34,6 +34,8 @@ ifeq ($(CONFIG_LIBTRACEEVENT),y) perf-$(CONFIG_TRACE) += trace/beauty/ endif +perf-util-y += trace/beauty/ + perf-$(CONFIG_LIBELF) += builtin-probe.o perf-bench-y += bench/ diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 0aba14f22a06..c81797ceec42 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -509,225 +509,6 @@ arm64-sysreg-defs-clean: $(Q)$(MAKE) -C $(arm64_gen_sysreg_dir) O=$(arm64_gen_sysreg_outdir) \ prefix= subdir= clean > /dev/null -beauty_linux_dir := $(srctree)/tools/perf/trace/beauty/include/linux/ -beauty_uapi_linux_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/linux/ -beauty_uapi_sound_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/sound/ -beauty_arch_asm_dir := $(srctree)/tools/perf/trace/beauty/arch/x86/include/asm/ -beauty_x86_arch_asm_uapi_dir := $(srctree)/tools/perf/trace/beauty/arch/x86/include/uapi/asm/ - -linux_uapi_dir := $(srctree)/tools/include/uapi/linux -asm_generic_uapi_dir := $(srctree)/tools/include/uapi/asm-generic -arch_asm_uapi_dir := $(srctree)/tools/arch/$(SRCARCH)/include/uapi/asm/ -x86_arch_asm_dir := $(srctree)/tools/arch/x86/include/asm/ - -beauty_outdir := $(OUTPUT)trace/beauty/generated -beauty_ioctl_outdir := $(beauty_outdir)/ioctl - -# Create output directory if not already present -$(shell [ -d '$(beauty_ioctl_outdir)' ] || mkdir -p '$(beauty_ioctl_outdir)') - -syscall_array := $(beauty_outdir)/syscalltbl.c -syscall_tbl := $(srctree)/tools/perf/trace/beauty/syscalltbl.sh -syscall_tbl_data := $(srctree)/tools/scripts/syscall.tbl \ - $(wildcard $(srctree)/tools/perf/arch/*/entry/syscalls/syscall*.tbl) - -$(syscall_array): $(syscall_tbl) $(syscall_tbl_data) - $(Q)$(SHELL) '$(syscall_tbl)' $(srctree)/tools $@ - -fs_at_flags_array := $(beauty_outdir)/fs_at_flags_array.c -fs_at_flags_tbl := $(srctree)/tools/perf/trace/beauty/fs_at_flags.sh - -$(fs_at_flags_array): $(beauty_uapi_linux_dir)/fcntl.h $(fs_at_flags_tbl) - $(Q)$(SHELL) '$(fs_at_flags_tbl)' $(beauty_uapi_linux_dir) > $@ - -clone_flags_array := $(beauty_outdir)/clone_flags_array.c -clone_flags_tbl := $(srctree)/tools/perf/trace/beauty/clone.sh - -$(clone_flags_array): $(beauty_uapi_linux_dir)/sched.h $(clone_flags_tbl) - $(Q)$(SHELL) '$(clone_flags_tbl)' $(beauty_uapi_linux_dir) > $@ - -drm_ioctl_array := $(beauty_ioctl_outdir)/drm_ioctl_array.c -drm_hdr_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/drm -drm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/drm_ioctl.sh - -$(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl) - $(Q)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@ - -fadvise_advice_array := $(beauty_outdir)/fadvise_advice_array.c -fadvise_advice_tbl := $(srctree)/tools/perf/trace/beauty/fadvise.sh - -$(fadvise_advice_array): $(beauty_uapi_linux_dir)/fadvise.h $(fadvise_advice_tbl) - $(Q)$(SHELL) '$(fadvise_advice_tbl)' $(beauty_uapi_linux_dir) > $@ - -fsmount_arrays := $(beauty_outdir)/fsmount_arrays.c -fsmount_tbls := $(srctree)/tools/perf/trace/beauty/fsmount.sh - -$(fsmount_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsmount_tbls) - $(Q)$(SHELL) '$(fsmount_tbls)' $(beauty_uapi_linux_dir) > $@ - -fspick_arrays := $(beauty_outdir)/fspick_arrays.c -fspick_tbls := $(srctree)/tools/perf/trace/beauty/fspick.sh - -$(fspick_arrays): $(beauty_uapi_linux_dir)/mount.h $(fspick_tbls) - $(Q)$(SHELL) '$(fspick_tbls)' $(beauty_uapi_linux_dir) > $@ - -fsconfig_arrays := $(beauty_outdir)/fsconfig_arrays.c -fsconfig_tbls := $(srctree)/tools/perf/trace/beauty/fsconfig.sh - -$(fsconfig_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsconfig_tbls) - $(Q)$(SHELL) '$(fsconfig_tbls)' $(beauty_uapi_linux_dir) > $@ - -pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c -asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/ -pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh - -$(pkey_alloc_access_rights_array): $(asm_generic_hdr_dir)/mman-common.h $(pkey_alloc_access_rights_tbl) - $(Q)$(SHELL) '$(pkey_alloc_access_rights_tbl)' $(asm_generic_hdr_dir) > $@ - -sndrv_ctl_ioctl_array := $(beauty_ioctl_outdir)/sndrv_ctl_ioctl_array.c -sndrv_ctl_hdr_dir := $(srctree)/tools/include/uapi/sound -sndrv_ctl_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh - -$(sndrv_ctl_ioctl_array): $(beauty_uapi_sound_dir)/asound.h $(sndrv_ctl_ioctl_tbl) - $(Q)$(SHELL) '$(sndrv_ctl_ioctl_tbl)' $(beauty_uapi_sound_dir) > $@ - -sndrv_pcm_ioctl_array := $(beauty_ioctl_outdir)/sndrv_pcm_ioctl_array.c -sndrv_pcm_hdr_dir := $(srctree)/tools/include/uapi/sound -sndrv_pcm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh - -$(sndrv_pcm_ioctl_array): $(beauty_uapi_sound_dir)/asound.h $(sndrv_pcm_ioctl_tbl) - $(Q)$(SHELL) '$(sndrv_pcm_ioctl_tbl)' $(beauty_uapi_sound_dir) > $@ - -kcmp_type_array := $(beauty_outdir)/kcmp_type_array.c -kcmp_hdr_dir := $(srctree)/tools/include/uapi/linux/ -kcmp_type_tbl := $(srctree)/tools/perf/trace/beauty/kcmp_type.sh - -$(kcmp_type_array): $(kcmp_hdr_dir)/kcmp.h $(kcmp_type_tbl) - $(Q)$(SHELL) '$(kcmp_type_tbl)' $(kcmp_hdr_dir) > $@ - -kvm_ioctl_array := $(beauty_ioctl_outdir)/kvm_ioctl_array.c -kvm_hdr_dir := $(srctree)/tools/include/uapi/linux -kvm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/kvm_ioctl.sh - -$(kvm_ioctl_array): $(kvm_hdr_dir)/kvm.h $(kvm_ioctl_tbl) - $(Q)$(SHELL) '$(kvm_ioctl_tbl)' $(kvm_hdr_dir) > $@ - -socket_arrays := $(beauty_outdir)/socket.c -socket_tbl := $(srctree)/tools/perf/trace/beauty/socket.sh - -$(socket_arrays): $(linux_uapi_dir)/in.h $(beauty_linux_dir)/socket.h $(socket_tbl) - $(Q)$(SHELL) '$(socket_tbl)' $(linux_uapi_dir) $(beauty_linux_dir) > $@ - -sockaddr_arrays := $(beauty_outdir)/sockaddr.c -sockaddr_tbl := $(srctree)/tools/perf/trace/beauty/sockaddr.sh - -$(sockaddr_arrays): $(beauty_linux_dir)/socket.h $(sockaddr_tbl) - $(Q)$(SHELL) '$(sockaddr_tbl)' $(beauty_linux_dir) > $@ - -vhost_virtio_ioctl_array := $(beauty_ioctl_outdir)/vhost_virtio_ioctl_array.c -vhost_virtio_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/vhost_virtio_ioctl.sh - -$(vhost_virtio_ioctl_array): $(beauty_uapi_linux_dir)/vhost.h $(vhost_virtio_ioctl_tbl) - $(Q)$(SHELL) '$(vhost_virtio_ioctl_tbl)' $(beauty_uapi_linux_dir) > $@ - -perf_ioctl_array := $(beauty_ioctl_outdir)/perf_ioctl_array.c -perf_hdr_dir := $(srctree)/tools/include/uapi/linux -perf_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/perf_ioctl.sh - -$(perf_ioctl_array): $(perf_hdr_dir)/perf_event.h $(perf_ioctl_tbl) - $(Q)$(SHELL) '$(perf_ioctl_tbl)' $(perf_hdr_dir) > $@ - -madvise_behavior_array := $(beauty_outdir)/madvise_behavior_array.c -madvise_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/ -madvise_behavior_tbl := $(srctree)/tools/perf/trace/beauty/madvise_behavior.sh - -$(madvise_behavior_array): $(madvise_hdr_dir)/mman-common.h $(madvise_behavior_tbl) - $(Q)$(SHELL) '$(madvise_behavior_tbl)' $(madvise_hdr_dir) > $@ - -mmap_flags_array := $(beauty_outdir)/mmap_flags_array.c -mmap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mmap_flags.sh - -$(mmap_flags_array): $(linux_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl) - $(Q)$(SHELL) '$(mmap_flags_tbl)' $(linux_uapi_dir) $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ - -mremap_flags_array := $(beauty_outdir)/mremap_flags_array.c -mremap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mremap_flags.sh - -$(mremap_flags_array): $(linux_uapi_dir)/mman.h $(mremap_flags_tbl) - $(Q)$(SHELL) '$(mremap_flags_tbl)' $(linux_uapi_dir) > $@ - -mount_flags_array := $(beauty_outdir)/mount_flags_array.c -mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.sh - -$(mount_flags_array): $(beauty_uapi_linux_dir)/mount.h $(mount_flags_tbl) - $(Q)$(SHELL) '$(mount_flags_tbl)' $(beauty_uapi_linux_dir) > $@ - -move_mount_flags_array := $(beauty_outdir)/move_mount_flags_array.c -move_mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/move_mount_flags.sh - -$(move_mount_flags_array): $(beauty_uapi_linux_dir)/mount.h $(move_mount_flags_tbl) - $(Q)$(SHELL) '$(move_mount_flags_tbl)' $(beauty_uapi_linux_dir) > $@ - -mmap_prot_array := $(beauty_outdir)/mmap_prot_array.c -mmap_prot_tbl := $(srctree)/tools/perf/trace/beauty/mmap_prot.sh - -$(mmap_prot_array): $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_prot_tbl) - $(Q)$(SHELL) '$(mmap_prot_tbl)' $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ - -prctl_option_array := $(beauty_outdir)/prctl_option_array.c -prctl_option_tbl := $(srctree)/tools/perf/trace/beauty/prctl_option.sh - -$(prctl_option_array): $(beauty_uapi_linux_dir)/prctl.h $(prctl_option_tbl) - $(Q)$(SHELL) '$(prctl_option_tbl)' $(beauty_uapi_linux_dir) > $@ - -usbdevfs_ioctl_array := $(beauty_ioctl_outdir)/usbdevfs_ioctl_array.c -usbdevfs_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/usbdevfs_ioctl.sh - -$(usbdevfs_ioctl_array): $(beauty_uapi_linux_dir)/usbdevice_fs.h $(usbdevfs_ioctl_tbl) - $(Q)$(SHELL) '$(usbdevfs_ioctl_tbl)' $(beauty_uapi_linux_dir) > $@ - -x86_arch_prctl_code_array := $(beauty_outdir)/x86_arch_prctl_code_array.c -x86_arch_prctl_code_tbl := $(srctree)/tools/perf/trace/beauty/x86_arch_prctl.sh - -$(x86_arch_prctl_code_array): $(beauty_x86_arch_asm_uapi_dir)/prctl.h $(x86_arch_prctl_code_tbl) - $(Q)$(SHELL) '$(x86_arch_prctl_code_tbl)' $(beauty_x86_arch_asm_uapi_dir) > $@ - -x86_arch_irq_vectors_array := $(beauty_outdir)/x86_arch_irq_vectors_array.c -x86_arch_irq_vectors_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh - -$(x86_arch_irq_vectors_array): $(beauty_arch_asm_dir)/irq_vectors.h $(x86_arch_irq_vectors_tbl) - $(Q)$(SHELL) '$(x86_arch_irq_vectors_tbl)' $(beauty_arch_asm_dir) > $@ - -x86_arch_MSRs_array := $(beauty_outdir)/x86_arch_MSRs_array.c -x86_arch_MSRs_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_msr.sh - -$(x86_arch_MSRs_array): $(x86_arch_asm_dir)/msr-index.h $(x86_arch_MSRs_tbl) - $(Q)$(SHELL) '$(x86_arch_MSRs_tbl)' $(x86_arch_asm_dir) > $@ - -rename_flags_array := $(beauty_outdir)/rename_flags_array.c -rename_flags_tbl := $(srctree)/tools/perf/trace/beauty/rename_flags.sh - -$(rename_flags_array): $(beauty_uapi_linux_dir)/fs.h $(rename_flags_tbl) - $(Q)$(SHELL) '$(rename_flags_tbl)' $(beauty_uapi_linux_dir) > $@ - -arch_errno_name_array := $(beauty_outdir)/arch_errno_name_array.c -arch_errno_hdr_dir := $(srctree)/tools -arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh - -$(arch_errno_name_array): $(arch_errno_tbl) - $(Q)$(SHELL) '$(arch_errno_tbl)' '$(patsubst -%,,$(CC))' $(arch_errno_hdr_dir) > $@ - -statx_mask_array := $(beauty_outdir)/statx_mask_array.c -statx_mask_tbl := $(srctree)/tools/perf/trace/beauty/statx_mask.sh - -$(statx_mask_array): $(beauty_uapi_linux_dir)/stat.h $(statx_mask_tbl) - $(Q)$(SHELL) '$(statx_mask_tbl)' $(beauty_uapi_linux_dir) > $@ - -sync_file_range_arrays := $(beauty_outdir)/sync_file_range_arrays.c -sync_file_range_tbls := $(srctree)/tools/perf/trace/beauty/sync_file_range.sh - -$(sync_file_range_arrays): $(beauty_uapi_linux_dir)/fs.h $(sync_file_range_tbls) - $(Q)$(SHELL) '$(sync_file_range_tbls)' $(beauty_uapi_linux_dir) > $@ TESTS_CORESIGHT_DIR := $(srctree)/tools/perf/tests/shell/coresight @@ -848,38 +629,6 @@ build-dir = $(or $(__build-dir),.) prepare: $(OUTPUT)PERF-VERSION-FILE archheaders \ arm64-sysreg-defs \ - $(syscall_array) \ - $(fs_at_flags_array) \ - $(clone_flags_array) \ - $(drm_ioctl_array) \ - $(fadvise_advice_array) \ - $(fsconfig_arrays) \ - $(fsmount_arrays) \ - $(fspick_arrays) \ - $(pkey_alloc_access_rights_array) \ - $(sndrv_pcm_ioctl_array) \ - $(sndrv_ctl_ioctl_array) \ - $(kcmp_type_array) \ - $(kvm_ioctl_array) \ - $(socket_arrays) \ - $(sockaddr_arrays) \ - $(vhost_virtio_ioctl_array) \ - $(madvise_behavior_array) \ - $(mmap_flags_array) \ - $(mmap_prot_array) \ - $(mremap_flags_array) \ - $(mount_flags_array) \ - $(move_mount_flags_array) \ - $(perf_ioctl_array) \ - $(prctl_option_array) \ - $(usbdevfs_ioctl_array) \ - $(x86_arch_irq_vectors_array) \ - $(x86_arch_MSRs_array) \ - $(x86_arch_prctl_code_array) \ - $(rename_flags_array) \ - $(arch_errno_name_array) \ - $(statx_mask_array) \ - $(sync_file_range_arrays) \ $(LIBAPI) \ $(LIBPERF) \ $(LIBSUBCMD) \ @@ -1299,35 +1048,8 @@ clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $( TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE \ $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \ $(OUTPUT)util/intel-pt-decoder/inat-tables.c \ - $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \ - $(OUTPUT)$(fadvise_advice_array) \ - $(OUTPUT)$(fsconfig_arrays) \ - $(OUTPUT)$(fsmount_arrays) \ - $(OUTPUT)$(fspick_arrays) \ - $(OUTPUT)$(madvise_behavior_array) \ - $(OUTPUT)$(mmap_flags_array) \ - $(OUTPUT)$(mmap_prot_array) \ - $(OUTPUT)$(mremap_flags_array) \ - $(OUTPUT)$(mount_flags_array) \ - $(OUTPUT)$(move_mount_flags_array) \ - $(OUTPUT)$(drm_ioctl_array) \ - $(OUTPUT)$(pkey_alloc_access_rights_array) \ - $(OUTPUT)$(sndrv_ctl_ioctl_array) \ - $(OUTPUT)$(sndrv_pcm_ioctl_array) \ - $(OUTPUT)$(kvm_ioctl_array) \ - $(OUTPUT)$(kcmp_type_array) \ - $(OUTPUT)$(socket_arrays) \ - $(OUTPUT)$(sockaddr_arrays) \ - $(OUTPUT)$(vhost_virtio_ioctl_array) \ - $(OUTPUT)$(perf_ioctl_array) \ - $(OUTPUT)$(prctl_option_array) \ - $(OUTPUT)$(usbdevfs_ioctl_array) \ - $(OUTPUT)$(x86_arch_irq_vectors_array) \ - $(OUTPUT)$(x86_arch_MSRs_array) \ - $(OUTPUT)$(x86_arch_prctl_code_array) \ - $(OUTPUT)$(rename_flags_array) \ - $(OUTPUT)$(arch_errno_name_array) \ - $(OUTPUT)$(sync_file_range_arrays) + $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c + $(Q)$(RM) -r $(OUTPUT)trace/beauty/generated $(call QUIET_CLEAN, Documentation) \ $(MAKE) -C $(DOC_DIR) O=$(OUTPUT) clean >/dev/null diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index e58c49d047a2..e6fe8e13f4e7 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -60,12 +60,13 @@ #include "callchain.h" #include "print_binary.h" #include "string2.h" -#include "syscalltbl.h" +#include "trace/beauty/syscalltbl.h" #include "../perf.h" #include "trace_augment.h" #include "dwarf-regs.h" #include <errno.h> +#include <sys/stat.h> #include <inttypes.h> #include <poll.h> #include <signal.h> @@ -234,6 +235,16 @@ struct trace { const char *uid_str; }; +bool trace__show_zeros(const struct trace *trace) +{ + return trace->show_zeros; +} + +struct machine *trace__host(const struct trace *trace) +{ + return trace->host; +} + static void trace__load_vmlinux_btf(struct trace *trace __maybe_unused) { #ifdef HAVE_LIBBPF_SUPPORT @@ -776,9 +787,7 @@ static const char *fsmount_flags[] = { }; static DEFINE_STRARRAY(fsmount_flags, "FSMOUNT_"); -#include "trace/beauty/generated/fsconfig_arrays.c" -static DEFINE_STRARRAY(fsconfig_cmds, "FSCONFIG_"); static const char *epoll_ctl_ops[] = { "ADD", "DEL", "MOD", }; static DEFINE_STRARRAY_OFFSET(epoll_ctl_ops, "EPOLL_CTL_", 1); @@ -1128,20 +1137,7 @@ static bool syscall_arg__strtoul_btf_type(char *bf __maybe_unused, size_t size _ .parm = &strarray__##array, \ .show_zero = true, } -#include "trace/beauty/eventfd.c" -#include "trace/beauty/futex_op.c" -#include "trace/beauty/futex_val3.c" -#include "trace/beauty/mmap.c" -#include "trace/beauty/mode_t.c" -#include "trace/beauty/msg_flags.c" -#include "trace/beauty/open_flags.c" -#include "trace/beauty/perf_event_open.c" -#include "trace/beauty/pid.c" -#include "trace/beauty/sched_policy.c" -#include "trace/beauty/seccomp.c" -#include "trace/beauty/signum.c" -#include "trace/beauty/socket_type.c" -#include "trace/beauty/waitid_options.c" + static const struct syscall_fmt syscall_fmts[] = { { .name = "access", diff --git a/tools/perf/trace/beauty/Build b/tools/perf/trace/beauty/Build index 561590ee8cda..83c1919ecebd 100644 --- a/tools/perf/trace/beauty/Build +++ b/tools/perf/trace/beauty/Build @@ -19,6 +19,23 @@ perf-y += socket.o perf-y += statx.o perf-y += sync_file_range.o perf-y += timespec.o +perf-util-y += syscalltbl.o +perf-y += fsconfig.o +perf-y += eventfd.o +perf-y += futex_op.o +perf-y += futex_val3.o +perf-y += mmap.o +perf-y += mode_t.o +perf-y += msg_flags.o +perf-y += open_flags.o +perf-y += perf_event_open.o +perf-y += pid.o +perf-y += sched_policy.o +perf-y += seccomp.o +perf-y += signum.o +perf-y += socket_type.o +perf-y += waitid_options.o +perf-util-y += arch_errno_names.o perf-y += tracepoints/ ifdef SHELLCHECK @@ -34,3 +51,266 @@ $(OUTPUT)%.shellcheck_log: % $(Q)$(call echo-cmd,test)$(SHELLCHECK) "$<" > $@ || (cat $@ && rm $@ && false) perf-y += $(SHELL_TEST_LOGS) + +# --- Encapsulated Beauty Generation Rules --- +beauty_linux_dir := $(srctree)/tools/perf/trace/beauty/include/linux/ +beauty_uapi_linux_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/linux/ +beauty_uapi_sound_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/sound/ +beauty_arch_asm_dir := $(srctree)/tools/perf/trace/beauty/arch/x86/include/asm/ +beauty_x86_arch_asm_uapi_dir := $(srctree)/tools/perf/trace/beauty/arch/x86/include/uapi/asm/ + +linux_uapi_dir := $(srctree)/tools/include/uapi/linux +asm_generic_uapi_dir := $(srctree)/tools/include/uapi/asm-generic +arch_asm_uapi_dir := $(srctree)/tools/arch/$(SRCARCH)/include/uapi/asm/ +x86_arch_asm_dir := $(srctree)/tools/arch/x86/include/asm/ + +beauty_outdir := $(OUTPUT)trace/beauty/generated +beauty_ioctl_outdir := $(beauty_outdir)/ioctl + +# Output directories are dynamically created by $(call rule_mkdir) in recipes + +syscall_array := $(beauty_outdir)/syscalltbl.c +syscall_tbl := $(srctree)/tools/perf/trace/beauty/syscalltbl.sh +syscall_tbl_data := $(srctree)/tools/scripts/syscall.tbl \ + $(wildcard $(srctree)/tools/perf/arch/*/entry/syscalls/syscall*.tbl) + +$(syscall_array): $(syscall_tbl) $(syscall_tbl_data) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(syscall_tbl)' $(srctree)/tools $@ + +fs_at_flags_array := $(beauty_outdir)/fs_at_flags_array.c +fs_at_flags_tbl := $(srctree)/tools/perf/trace/beauty/fs_at_flags.sh + +$(fs_at_flags_array): $(beauty_uapi_linux_dir)/fcntl.h $(fs_at_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(fs_at_flags_tbl)' $(beauty_uapi_linux_dir) > $@ + +clone_flags_array := $(beauty_outdir)/clone_flags_array.c +clone_flags_tbl := $(srctree)/tools/perf/trace/beauty/clone.sh + +$(clone_flags_array): $(beauty_uapi_linux_dir)/sched.h $(clone_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(clone_flags_tbl)' $(beauty_uapi_linux_dir) > $@ + +drm_ioctl_array := $(beauty_ioctl_outdir)/drm_ioctl_array.c +drm_hdr_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/drm +drm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/drm_ioctl.sh + +$(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@ + +fadvise_advice_array := $(beauty_outdir)/fadvise_advice_array.c +fadvise_advice_tbl := $(srctree)/tools/perf/trace/beauty/fadvise.sh + +$(fadvise_advice_array): $(beauty_uapi_linux_dir)/fadvise.h $(fadvise_advice_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(fadvise_advice_tbl)' $(beauty_uapi_linux_dir) > $@ + +fsmount_arrays := $(beauty_outdir)/fsmount_arrays.c +fsmount_tbls := $(srctree)/tools/perf/trace/beauty/fsmount.sh + +$(fsmount_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsmount_tbls) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(fsmount_tbls)' $(beauty_uapi_linux_dir) > $@ + +fspick_arrays := $(beauty_outdir)/fspick_arrays.c +fspick_tbls := $(srctree)/tools/perf/trace/beauty/fspick.sh + +$(fspick_arrays): $(beauty_uapi_linux_dir)/mount.h $(fspick_tbls) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(fspick_tbls)' $(beauty_uapi_linux_dir) > $@ + +fsconfig_arrays := $(beauty_outdir)/fsconfig_arrays.c +fsconfig_tbls := $(srctree)/tools/perf/trace/beauty/fsconfig.sh + +$(fsconfig_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsconfig_tbls) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(fsconfig_tbls)' $(beauty_uapi_linux_dir) > $@ + +pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c +asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/ +pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh + +$(pkey_alloc_access_rights_array): $(asm_generic_hdr_dir)/mman-common.h $(pkey_alloc_access_rights_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(pkey_alloc_access_rights_tbl)' $(asm_generic_hdr_dir) > $@ + +sndrv_ctl_ioctl_array := $(beauty_ioctl_outdir)/sndrv_ctl_ioctl_array.c +sndrv_ctl_hdr_dir := $(srctree)/tools/include/uapi/sound +sndrv_ctl_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh + +$(sndrv_ctl_ioctl_array): $(beauty_uapi_sound_dir)/asound.h $(sndrv_ctl_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(sndrv_ctl_ioctl_tbl)' $(beauty_uapi_sound_dir) > $@ + +sndrv_pcm_ioctl_array := $(beauty_ioctl_outdir)/sndrv_pcm_ioctl_array.c +sndrv_pcm_hdr_dir := $(srctree)/tools/include/uapi/sound +sndrv_pcm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh + +$(sndrv_pcm_ioctl_array): $(beauty_uapi_sound_dir)/asound.h $(sndrv_pcm_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(sndrv_pcm_ioctl_tbl)' $(beauty_uapi_sound_dir) > $@ + +kcmp_type_array := $(beauty_outdir)/kcmp_type_array.c +kcmp_hdr_dir := $(srctree)/tools/include/uapi/linux/ +kcmp_type_tbl := $(srctree)/tools/perf/trace/beauty/kcmp_type.sh + +$(kcmp_type_array): $(kcmp_hdr_dir)/kcmp.h $(kcmp_type_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(kcmp_type_tbl)' $(kcmp_hdr_dir) > $@ + +kvm_ioctl_array := $(beauty_ioctl_outdir)/kvm_ioctl_array.c +kvm_hdr_dir := $(srctree)/tools/include/uapi/linux +kvm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/kvm_ioctl.sh + +$(kvm_ioctl_array): $(kvm_hdr_dir)/kvm.h $(kvm_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(kvm_ioctl_tbl)' $(kvm_hdr_dir) > $@ + +socket_arrays := $(beauty_outdir)/socket.c +socket_tbl := $(srctree)/tools/perf/trace/beauty/socket.sh + +$(socket_arrays): $(linux_uapi_dir)/in.h $(beauty_linux_dir)/socket.h $(socket_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(socket_tbl)' $(linux_uapi_dir) $(beauty_linux_dir) > $@ + +sockaddr_arrays := $(beauty_outdir)/sockaddr.c +sockaddr_tbl := $(srctree)/tools/perf/trace/beauty/sockaddr.sh + +$(sockaddr_arrays): $(beauty_linux_dir)/socket.h $(sockaddr_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(sockaddr_tbl)' $(beauty_linux_dir) > $@ + +vhost_virtio_ioctl_array := $(beauty_ioctl_outdir)/vhost_virtio_ioctl_array.c +vhost_virtio_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/vhost_virtio_ioctl.sh + +$(vhost_virtio_ioctl_array): $(beauty_uapi_linux_dir)/vhost.h $(vhost_virtio_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(vhost_virtio_ioctl_tbl)' $(beauty_uapi_linux_dir) > $@ + +perf_ioctl_array := $(beauty_ioctl_outdir)/perf_ioctl_array.c +perf_hdr_dir := $(srctree)/tools/include/uapi/linux +perf_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/perf_ioctl.sh + +$(perf_ioctl_array): $(perf_hdr_dir)/perf_event.h $(perf_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(perf_ioctl_tbl)' $(perf_hdr_dir) > $@ + +madvise_behavior_array := $(beauty_outdir)/madvise_behavior_array.c +madvise_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/ +madvise_behavior_tbl := $(srctree)/tools/perf/trace/beauty/madvise_behavior.sh + +$(madvise_behavior_array): $(madvise_hdr_dir)/mman-common.h $(madvise_behavior_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(madvise_behavior_tbl)' $(madvise_hdr_dir) > $@ + +mmap_flags_array := $(beauty_outdir)/mmap_flags_array.c +mmap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mmap_flags.sh + +$(mmap_flags_array): $(linux_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(mmap_flags_tbl)' $(linux_uapi_dir) $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ + +mremap_flags_array := $(beauty_outdir)/mremap_flags_array.c +mremap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mremap_flags.sh + +$(mremap_flags_array): $(linux_uapi_dir)/mman.h $(mremap_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(mremap_flags_tbl)' $(linux_uapi_dir) > $@ + +mount_flags_array := $(beauty_outdir)/mount_flags_array.c +mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.sh + +$(mount_flags_array): $(beauty_uapi_linux_dir)/mount.h $(mount_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(mount_flags_tbl)' $(beauty_uapi_linux_dir) > $@ + +move_mount_flags_array := $(beauty_outdir)/move_mount_flags_array.c +move_mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/move_mount_flags.sh + +$(move_mount_flags_array): $(beauty_uapi_linux_dir)/mount.h $(move_mount_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(move_mount_flags_tbl)' $(beauty_uapi_linux_dir) > $@ + +mmap_prot_array := $(beauty_outdir)/mmap_prot_array.c +mmap_prot_tbl := $(srctree)/tools/perf/trace/beauty/mmap_prot.sh + +$(mmap_prot_array): $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_prot_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(mmap_prot_tbl)' $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ + +prctl_option_array := $(beauty_outdir)/prctl_option_array.c +prctl_option_tbl := $(srctree)/tools/perf/trace/beauty/prctl_option.sh + +$(prctl_option_array): $(beauty_uapi_linux_dir)/prctl.h $(prctl_option_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(prctl_option_tbl)' $(beauty_uapi_linux_dir) > $@ + +usbdevfs_ioctl_array := $(beauty_ioctl_outdir)/usbdevfs_ioctl_array.c +usbdevfs_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/usbdevfs_ioctl.sh + +$(usbdevfs_ioctl_array): $(beauty_uapi_linux_dir)/usbdevice_fs.h $(usbdevfs_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(usbdevfs_ioctl_tbl)' $(beauty_uapi_linux_dir) > $@ + +x86_arch_prctl_code_array := $(beauty_outdir)/x86_arch_prctl_code_array.c +x86_arch_prctl_code_tbl := $(srctree)/tools/perf/trace/beauty/x86_arch_prctl.sh + +$(x86_arch_prctl_code_array): $(beauty_x86_arch_asm_uapi_dir)/prctl.h $(x86_arch_prctl_code_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(x86_arch_prctl_code_tbl)' $(beauty_x86_arch_asm_uapi_dir) > $@ + + +rename_flags_array := $(beauty_outdir)/rename_flags_array.c +rename_flags_tbl := $(srctree)/tools/perf/trace/beauty/rename_flags.sh + +$(rename_flags_array): $(beauty_uapi_linux_dir)/fs.h $(rename_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(rename_flags_tbl)' $(beauty_uapi_linux_dir) > $@ + + +statx_mask_array := $(beauty_outdir)/statx_mask_array.c +statx_mask_tbl := $(srctree)/tools/perf/trace/beauty/statx_mask.sh + +$(statx_mask_array): $(beauty_uapi_linux_dir)/stat.h $(statx_mask_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(statx_mask_tbl)' $(beauty_uapi_linux_dir) > $@ + +sync_file_range_arrays := $(beauty_outdir)/sync_file_range_arrays.c +sync_file_range_tbls := $(srctree)/tools/perf/trace/beauty/sync_file_range.sh + +$(sync_file_range_arrays): $(beauty_uapi_linux_dir)/fs.h $(sync_file_range_tbls) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(sync_file_range_tbls)' $(beauty_uapi_linux_dir) > $@ + +# --- Precise Local Prerequisites Binding --- +$(OUTPUT)trace/beauty/syscalltbl.o: $(syscall_array) +$(OUTPUT)trace/beauty/fsconfig.o: $(fsconfig_arrays) +$(OUTPUT)trace/beauty/clone.o: $(clone_flags_array) +$(OUTPUT)trace/beauty/fs_at_flags.o: $(fs_at_flags_array) +$(OUTPUT)trace/beauty/fsmount.o: $(fsmount_arrays) +$(OUTPUT)trace/beauty/fspick.o: $(fspick_arrays) +$(OUTPUT)trace/beauty/ioctl.o: $(drm_ioctl_array) $(sndrv_pcm_ioctl_array) $(sndrv_ctl_ioctl_array) $(kvm_ioctl_array) $(vhost_virtio_ioctl_array) $(perf_ioctl_array) $(usbdevfs_ioctl_array) +$(OUTPUT)trace/beauty/kcmp.o: $(kcmp_type_array) +$(OUTPUT)trace/beauty/mmap.o: $(mmap_prot_array) $(mmap_flags_array) $(mremap_flags_array) $(madvise_behavior_array) +$(OUTPUT)trace/beauty/mount_flags.o: $(mount_flags_array) +$(OUTPUT)trace/beauty/move_mount.o: $(move_mount_flags_array) +$(OUTPUT)trace/beauty/pkey_alloc.o: $(pkey_alloc_access_rights_array) +$(OUTPUT)trace/beauty/prctl.o: $(prctl_option_array) +$(OUTPUT)trace/beauty/renameat.o: $(rename_flags_array) +$(OUTPUT)trace/beauty/sockaddr.o: $(sockaddr_arrays) +$(OUTPUT)trace/beauty/socket.o: $(socket_arrays) +$(OUTPUT)trace/beauty/statx.o: $(statx_mask_array) +$(OUTPUT)trace/beauty/sync_file_range.o: $(sync_file_range_arrays) +$(OUTPUT)trace/beauty/arch_prctl.o: $(x86_arch_prctl_code_array) + +arch_errno_name_array := $(beauty_outdir)/arch_errno_name_array.c +arch_errno_hdr_dir := $(srctree)/tools +arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh + +$(arch_errno_name_array): $(arch_errno_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(arch_errno_tbl)' '$(patsubst -%,,$(CC))' $(arch_errno_hdr_dir) > $@ + +$(OUTPUT)trace/beauty/arch_errno_names.o: $(arch_errno_name_array) diff --git a/tools/perf/trace/beauty/arch_errno_names.c b/tools/perf/trace/beauty/arch_errno_names.c index ede031c3a9e0..156c6537e747 100644 --- a/tools/perf/trace/beauty/arch_errno_names.c +++ b/tools/perf/trace/beauty/arch_errno_names.c @@ -1 +1,3 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "util/env.h" #include "trace/beauty/generated/arch_errno_name_array.c" diff --git a/tools/perf/trace/beauty/arch_errno_names.sh b/tools/perf/trace/beauty/arch_errno_names.sh index b22890b8d272..d48d8561a7bb 100755 --- a/tools/perf/trace/beauty/arch_errno_names.sh +++ b/tools/perf/trace/beauty/arch_errno_names.sh @@ -57,7 +57,7 @@ create_arch_errno_table_func() archlist="$1" default="$2" - printf 'static arch_syscalls__strerrno_t *\n' + printf 'arch_syscalls__strerrno_t *\n' printf 'arch_syscalls__strerrno_function(const char *arch)\n' printf '{\n' for arch in $archlist; do diff --git a/tools/perf/trace/beauty/beauty.h b/tools/perf/trace/beauty/beauty.h index 0a07ad158f87..931c4a80fea9 100644 --- a/tools/perf/trace/beauty/beauty.h +++ b/tools/perf/trace/beauty/beauty.h @@ -35,6 +35,8 @@ bool strarray__strtoul(struct strarray *sa, char *bf, size_t size, u64 *ret); bool strarray__strtoul_flags(struct strarray *sa, char *bf, size_t size, u64 *ret); struct trace; +bool trace__show_zeros(const struct trace *trace); +struct machine *trace__host(const struct trace *trace); struct thread; struct file { @@ -265,4 +267,62 @@ size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool sh void syscall_arg__set_ret_scnprintf(struct syscall_arg *arg, size_t (*ret_scnprintf)(char *bf, size_t size, struct syscall_arg *arg)); +extern struct strarray strarray__fsconfig_cmds; + +size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_EFD_FLAGS syscall_arg__scnprintf_eventfd_flags + +size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_FUTEX_OP syscall_arg__scnprintf_futex_op + +size_t syscall_arg__scnprintf_futex_val3(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_FUTEX_VAL3 syscall_arg__scnprintf_futex_val3 + +size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot + +extern struct strarray strarray__mmap_flags; + +size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags + +size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_MREMAP_FLAGS syscall_arg__scnprintf_mremap_flags + +size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior + +size_t syscall_arg__scnprintf_mode_t(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_MODE_T syscall_arg__scnprintf_mode_t + +size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_MSG_FLAGS syscall_arg__scnprintf_msg_flags + +size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_PERF_FLAGS syscall_arg__scnprintf_perf_flags + +size_t syscall_arg__scnprintf_perf_event_attr(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_PERF_ATTR syscall_arg__scnprintf_perf_event_attr +#define SCA_PERF_ATTR_FROM_USER(argname) \ + { .scnprintf = SCA_PERF_ATTR, \ + .from_user = true, } + +size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_SCHED_POLICY syscall_arg__scnprintf_sched_policy + +size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_SECCOMP_OP syscall_arg__scnprintf_seccomp_op + +size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags + +size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_SIGNUM syscall_arg__scnprintf_signum + +size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_SK_TYPE syscall_arg__scnprintf_socket_type + +size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_WAITID_OPTIONS syscall_arg__scnprintf_waitid_options + #endif /* _PERF_TRACE_BEAUTY_H */ diff --git a/tools/perf/trace/beauty/eventfd.c b/tools/perf/trace/beauty/eventfd.c index 4bab106213c6..3fc552c9c360 100644 --- a/tools/perf/trace/beauty/eventfd.c +++ b/tools/perf/trace/beauty/eventfd.c @@ -11,7 +11,9 @@ #define EFD_CLOEXEC 02000000 #endif -static size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "EFD_"; @@ -36,4 +38,4 @@ static size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct return printed; } -#define SCA_EFD_FLAGS syscall_arg__scnprintf_eventfd_flags + diff --git a/tools/perf/trace/beauty/fsconfig.c b/tools/perf/trace/beauty/fsconfig.c new file mode 100644 index 000000000000..98aa05315673 --- /dev/null +++ b/tools/perf/trace/beauty/fsconfig.c @@ -0,0 +1,5 @@ +// SPDX-License-Identifier: LGPL-2.1 +#include "trace/beauty/beauty.h" +#include "trace/beauty/generated/fsconfig_arrays.c" + +DEFINE_STRARRAY(fsconfig_cmds, "FSCONFIG_"); diff --git a/tools/perf/trace/beauty/futex_op.c b/tools/perf/trace/beauty/futex_op.c index 00365156782b..fb627780d381 100644 --- a/tools/perf/trace/beauty/futex_op.c +++ b/tools/perf/trace/beauty/futex_op.c @@ -17,7 +17,9 @@ #define FUTEX_CLOCK_REALTIME 256 #endif -static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "FUTEX_"; @@ -60,4 +62,4 @@ static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct sysc return printed; } -#define SCA_FUTEX_OP syscall_arg__scnprintf_futex_op + diff --git a/tools/perf/trace/beauty/futex_val3.c b/tools/perf/trace/beauty/futex_val3.c index 9114f7620571..d4d2fb117d39 100644 --- a/tools/perf/trace/beauty/futex_val3.c +++ b/tools/perf/trace/beauty/futex_val3.c @@ -5,7 +5,9 @@ #define FUTEX_BITSET_MATCH_ANY 0xffffffff #endif -static size_t syscall_arg__scnprintf_futex_val3(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_futex_val3(char *bf, size_t size, struct syscall_arg *arg) { const char *prefix = "FUTEX_BITSET_"; unsigned int bitset = arg->val; @@ -16,4 +18,4 @@ static size_t syscall_arg__scnprintf_futex_val3(char *bf, size_t size, struct sy return scnprintf(bf, size, "%#xd", bitset); } -#define SCA_FUTEX_VAL3 syscall_arg__scnprintf_futex_val3 + diff --git a/tools/perf/trace/beauty/mmap.c b/tools/perf/trace/beauty/mmap.c index 3c5e97b93dd5..f1a1012fd2a0 100644 --- a/tools/perf/trace/beauty/mmap.c +++ b/tools/perf/trace/beauty/mmap.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: LGPL-2.1 #include <linux/log2.h> +#include "trace/beauty/beauty.h" #include "trace/beauty/generated/mmap_prot_array.c" static DEFINE_STRARRAY(mmap_prot, "PROT_"); @@ -8,8 +9,7 @@ static size_t mmap__scnprintf_prot(unsigned long prot, char *bf, size_t size, bo { return strarray__scnprintf_flags(&strarray__mmap_prot, bf, size, show_prefix, prot); } - -static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, struct syscall_arg *arg) +size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, struct syscall_arg *arg) { unsigned long prot = arg->val; @@ -19,18 +19,18 @@ static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, struct sys return mmap__scnprintf_prot(prot, bf, size, arg->show_string_prefix); } -#define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot + #include "trace/beauty/generated/mmap_flags_array.c" -static DEFINE_STRARRAY(mmap_flags, "MAP_"); +DEFINE_STRARRAY(mmap_flags, "MAP_"); static size_t mmap__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix) { return strarray__scnprintf_flags(&strarray__mmap_flags, bf, size, show_prefix, flags); } -static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, - struct syscall_arg *arg) +size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, + struct syscall_arg *arg) { unsigned long flags = arg->val; @@ -40,7 +40,7 @@ static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, return mmap__scnprintf_flags(flags, bf, size, arg->show_string_prefix); } -#define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags + #include "trace/beauty/generated/mremap_flags_array.c" static DEFINE_STRARRAY(mremap_flags, "MREMAP_"); @@ -50,7 +50,7 @@ static size_t mremap__scnprintf_flags(unsigned long flags, char *bf, size_t size return strarray__scnprintf_flags(&strarray__mremap_flags, bf, size, show_prefix, flags); } -static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, struct syscall_arg *arg) +size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, struct syscall_arg *arg) { unsigned long flags = arg->val; @@ -60,7 +60,7 @@ static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, struct return mremap__scnprintf_flags(flags, bf, size, arg->show_string_prefix); } -#define SCA_MREMAP_FLAGS syscall_arg__scnprintf_mremap_flags + static size_t madvise__scnprintf_behavior(int behavior, char *bf, size_t size) { @@ -73,10 +73,10 @@ static size_t madvise__scnprintf_behavior(int behavior, char *bf, size_t size) return scnprintf(bf, size, "%#", behavior); } -static size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size, - struct syscall_arg *arg) +size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size, + struct syscall_arg *arg) { return madvise__scnprintf_behavior(arg->val, bf, size); } -#define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior + diff --git a/tools/perf/trace/beauty/mode_t.c b/tools/perf/trace/beauty/mode_t.c index 29a8fadfb7f9..7d7f89229513 100644 --- a/tools/perf/trace/beauty/mode_t.c +++ b/tools/perf/trace/beauty/mode_t.c @@ -20,7 +20,9 @@ #define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) #endif -static size_t syscall_arg__scnprintf_mode_t(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_mode_t(char *bf, size_t size, struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "S_"; @@ -68,4 +70,4 @@ static size_t syscall_arg__scnprintf_mode_t(char *bf, size_t size, struct syscal return printed; } -#define SCA_MODE_T syscall_arg__scnprintf_mode_t + diff --git a/tools/perf/trace/beauty/msg_flags.c b/tools/perf/trace/beauty/msg_flags.c index 2da581ff0c80..5721b2bee99f 100644 --- a/tools/perf/trace/beauty/msg_flags.c +++ b/tools/perf/trace/beauty/msg_flags.c @@ -27,8 +27,10 @@ # define MSG_CMSG_CLOEXEC 0x40000000 #endif -static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, - struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, + struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "MSG_"; @@ -73,4 +75,4 @@ static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, return printed; } -#define SCA_MSG_FLAGS syscall_arg__scnprintf_msg_flags + diff --git a/tools/perf/trace/beauty/open_flags.c b/tools/perf/trace/beauty/open_flags.c index 78f6566ef110..a0396f9732ad 100644 --- a/tools/perf/trace/beauty/open_flags.c +++ b/tools/perf/trace/beauty/open_flags.c @@ -2,6 +2,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include "trace/beauty/beauty.h" #ifndef O_DIRECT #define O_DIRECT 00040000 diff --git a/tools/perf/trace/beauty/perf_event_open.c b/tools/perf/trace/beauty/perf_event_open.c index 9f1ed989c775..d4e0f7816423 100644 --- a/tools/perf/trace/beauty/perf_event_open.c +++ b/tools/perf/trace/beauty/perf_event_open.c @@ -1,4 +1,7 @@ // SPDX-License-Identifier: LGPL-2.1 +#include <linux/perf_event.h> +#include "util/evsel_fprintf.h" + #ifndef PERF_FLAG_FD_NO_GROUP # define PERF_FLAG_FD_NO_GROUP (1UL << 0) #endif @@ -15,8 +18,10 @@ # define PERF_FLAG_FD_CLOEXEC (1UL << 3) /* O_CLOEXEC */ #endif -static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, - struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, + struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "PERF_"; @@ -43,7 +48,7 @@ static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, return printed; } -#define SCA_PERF_FLAGS syscall_arg__scnprintf_perf_flags + struct attr_fprintf_args { size_t size, printed; @@ -76,10 +81,11 @@ static size_t perf_event_attr___scnprintf(struct perf_event_attr *attr, char *bf static size_t syscall_arg__scnprintf_augmented_perf_event_attr(struct syscall_arg *arg, char *bf, size_t size) { - return perf_event_attr___scnprintf((void *)arg->augmented.args->value, bf, size, arg->trace->show_zeros); + return perf_event_attr___scnprintf((void *)arg->augmented.args->value, bf, size, + trace__show_zeros(arg->trace)); } -static size_t syscall_arg__scnprintf_perf_event_attr(char *bf, size_t size, struct syscall_arg *arg) +size_t syscall_arg__scnprintf_perf_event_attr(char *bf, size_t size, struct syscall_arg *arg) { if (arg->augmented.args) return syscall_arg__scnprintf_augmented_perf_event_attr(arg, bf, size); @@ -87,8 +93,4 @@ static size_t syscall_arg__scnprintf_perf_event_attr(char *bf, size_t size, stru return scnprintf(bf, size, "%#lx", arg->val); } -#define SCA_PERF_ATTR syscall_arg__scnprintf_perf_event_attr -// 'argname' is just documentational at this point, to remove the previous comment with that info -#define SCA_PERF_ATTR_FROM_USER(argname) \ - { .scnprintf = SCA_PERF_ATTR, \ - .from_user = true, } + diff --git a/tools/perf/trace/beauty/pid.c b/tools/perf/trace/beauty/pid.c index 8f9c9950f8ba..cca4a3a5d9bd 100644 --- a/tools/perf/trace/beauty/pid.c +++ b/tools/perf/trace/beauty/pid.c @@ -1,11 +1,14 @@ // SPDX-License-Identifier: LGPL-2.1 +#include "trace/beauty/beauty.h" +#include "util/machine.h" +#include "util/thread.h" size_t syscall_arg__scnprintf_pid(char *bf, size_t size, struct syscall_arg *arg) { int pid = arg->val; struct trace *trace = arg->trace; size_t printed = scnprintf(bf, size, "%d", pid); - struct thread *thread = machine__findnew_thread(trace->host, pid, pid); + struct thread *thread = machine__findnew_thread(trace__host(trace), pid, pid); if (thread != NULL) { if (!thread__comm_set(thread)) diff --git a/tools/perf/trace/beauty/sched_policy.c b/tools/perf/trace/beauty/sched_policy.c index 68aa59eeed8d..7f7928d396be 100644 --- a/tools/perf/trace/beauty/sched_policy.c +++ b/tools/perf/trace/beauty/sched_policy.c @@ -14,8 +14,10 @@ #define SCHED_RESET_ON_FORK 0x40000000 #endif -static size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size, - struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size, + struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "SCHED_"; @@ -47,4 +49,4 @@ static size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size, return printed; } -#define SCA_SCHED_POLICY syscall_arg__scnprintf_sched_policy + diff --git a/tools/perf/trace/beauty/seccomp.c b/tools/perf/trace/beauty/seccomp.c index 637722e2796b..b04555a364e2 100644 --- a/tools/perf/trace/beauty/seccomp.c +++ b/tools/perf/trace/beauty/seccomp.c @@ -6,7 +6,9 @@ #define SECCOMP_SET_MODE_FILTER 1 #endif -static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "SECCOMP_SET_MODE_"; @@ -24,14 +26,14 @@ static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct sy return printed; } -#define SCA_SECCOMP_OP syscall_arg__scnprintf_seccomp_op + #ifndef SECCOMP_FILTER_FLAG_TSYNC #define SECCOMP_FILTER_FLAG_TSYNC 1 #endif -static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size, - struct syscall_arg *arg) +size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size, + struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "SECCOMP_FILTER_FLAG_"; @@ -52,4 +54,4 @@ static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size, return printed; } -#define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags + diff --git a/tools/perf/trace/beauty/signum.c b/tools/perf/trace/beauty/signum.c index 21220c56500a..0303a6e298c8 100644 --- a/tools/perf/trace/beauty/signum.c +++ b/tools/perf/trace/beauty/signum.c @@ -1,7 +1,9 @@ // SPDX-License-Identifier: LGPL-2.1 #include <signal.h> -static size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "SIG"; @@ -54,4 +56,4 @@ static size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscal return scnprintf(bf, size, "%#x", sig); } -#define SCA_SIGNUM syscall_arg__scnprintf_signum + diff --git a/tools/perf/trace/beauty/socket_type.c b/tools/perf/trace/beauty/socket_type.c index bed8d5761ca8..c116b61a6ea9 100644 --- a/tools/perf/trace/beauty/socket_type.c +++ b/tools/perf/trace/beauty/socket_type.c @@ -18,7 +18,9 @@ #define SOCK_TYPE_MASK 0xf #endif -static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "SOCK_"; @@ -60,4 +62,4 @@ static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct s return printed; } -#define SCA_SK_TYPE syscall_arg__scnprintf_socket_type + diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/trace/beauty/syscalltbl.c similarity index 100% rename from tools/perf/util/syscalltbl.c rename to tools/perf/trace/beauty/syscalltbl.c diff --git a/tools/perf/util/syscalltbl.h b/tools/perf/trace/beauty/syscalltbl.h similarity index 100% rename from tools/perf/util/syscalltbl.h rename to tools/perf/trace/beauty/syscalltbl.h diff --git a/tools/perf/trace/beauty/tracepoints/Build b/tools/perf/trace/beauty/tracepoints/Build index e35087fdd108..392677319c6a 100644 --- a/tools/perf/trace/beauty/tracepoints/Build +++ b/tools/perf/trace/beauty/tracepoints/Build @@ -1,2 +1,24 @@ perf-y += x86_irq_vectors.o perf-y += x86_msr.o + +# --- Local Encapsulated Tracepoint Rules --- +beauty_outdir := $(OUTPUT)trace/beauty/generated +beauty_arch_asm_dir := $(srctree)/tools/perf/trace/beauty/arch/x86/include/asm/ +x86_arch_asm_dir := $(srctree)/tools/arch/x86/include/asm/ + +x86_arch_irq_vectors_array := $(beauty_outdir)/x86_arch_irq_vectors_array.c +x86_arch_irq_vectors_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh + +$(x86_arch_irq_vectors_array): $(beauty_arch_asm_dir)/irq_vectors.h $(x86_arch_irq_vectors_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(x86_arch_irq_vectors_tbl)' $(beauty_arch_asm_dir) > $@ + +x86_arch_MSRs_array := $(beauty_outdir)/x86_arch_MSRs_array.c +x86_arch_MSRs_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_msr.sh + +$(x86_arch_MSRs_array): $(x86_arch_asm_dir)/msr-index.h $(x86_arch_MSRs_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(x86_arch_MSRs_tbl)' $(x86_arch_asm_dir) > $@ + +$(OUTPUT)trace/beauty/tracepoints/x86_irq_vectors.o: $(x86_arch_irq_vectors_array) +$(OUTPUT)trace/beauty/tracepoints/x86_msr.o: $(x86_arch_MSRs_array) diff --git a/tools/perf/trace/beauty/waitid_options.c b/tools/perf/trace/beauty/waitid_options.c index d4d10b33ba0e..b3bd21162d6b 100644 --- a/tools/perf/trace/beauty/waitid_options.c +++ b/tools/perf/trace/beauty/waitid_options.c @@ -2,8 +2,10 @@ #include <sys/types.h> #include <sys/wait.h> -static size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size, - struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size, + struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "W"; @@ -26,4 +28,4 @@ static size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size, return printed; } -#define SCA_WAITID_OPTIONS syscall_arg__scnprintf_waitid_options + diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 70cc91d00804..abc9a2926e85 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -75,7 +75,7 @@ perf-util-y += sample.o perf-util-y += sample-raw.o perf-util-y += s390-sample-raw.o perf-util-y += amd-sample-raw.o -perf-util-$(CONFIG_TRACE) += syscalltbl.o + perf-util-y += ordered-events.o perf-util-y += namespaces.o perf-util-y += comm.o @@ -441,3 +441,5 @@ $(OUTPUT)%.pylint_log: % $(Q)$(call echo-cmd,test)pylint "$<" > $@ || (cat $@ && rm $@ && false) perf-util-y += $(PYLINT_TEST_LOGS) + + diff --git a/tools/perf/util/bpf-trace-summary.c b/tools/perf/util/bpf-trace-summary.c index cf6e1e4402d5..9a31dbf06cbb 100644 --- a/tools/perf/util/bpf-trace-summary.c +++ b/tools/perf/util/bpf-trace-summary.c @@ -6,7 +6,7 @@ #include <stdlib.h> #include "dwarf-regs.h" /* for EM_HOST */ -#include "syscalltbl.h" +#include "trace/beauty/syscalltbl.h" #include "util/cgroup.h" #include "util/hashmap.h" #include "util/trace.h" diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index 1e54e2c86360..e694ae14686a 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -635,9 +635,7 @@ const char *perf_env__arch(struct perf_env *env) return normalize_arch(arch_name); } -#if defined(HAVE_LIBTRACEEVENT) -#include "trace/beauty/arch_errno_names.c" -#endif + const char *perf_env__arch_strerrno(struct perf_env *env __maybe_unused, int err __maybe_unused) { diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h index c7052ac1f856..739d884fc236 100644 --- a/tools/perf/util/env.h +++ b/tools/perf/util/env.h @@ -189,6 +189,7 @@ void cpu_cache_level__free(struct cpu_cache_level *cache); const char *perf_env__arch(struct perf_env *env); const char *perf_env__arch_strerrno(struct perf_env *env, int err); +arch_syscalls__strerrno_t *arch_syscalls__strerrno_function(const char *arch); const char *perf_env__cpuid(struct perf_env *env); const char *perf_env__raw_arch(struct perf_env *env); int perf_env__nr_cpus_avail(struct perf_env *env); -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* Re: [PATCH v1 02/14] perf trace beauty: Make beauty generated C code standalone .o files 2026-05-12 5:35 ` [PATCH v1 02/14] perf trace beauty: Make beauty generated C code standalone .o files Ian Rogers @ 2026-05-13 5:21 ` sashiko-bot 0 siblings, 0 replies; 36+ messages in thread From: sashiko-bot @ 2026-05-13 5:21 UTC (permalink / raw) To: Ian Rogers; +Cc: bpf, linux-perf-users Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The commit message incorrectly states that it uses a conditional kbuild hook for `CONFIG_TRACE`, but the patch adds it unconditionally. -- commit b8d8fe14745ce243d9ff4d75f580a2b157dc3294 Author: Ian Rogers <irogers@google.com> perf trace beauty: Make beauty generated C code standalone .o files This commit refactors the perf trace beauty framework to compile generated code as independent standalone objects instead of inline inclusions. It also moves generation rules locally into the target Build files to improve parallel build startup. > 2. Create fsconfig.c and flatten embedded beauty .c files to compile as > independent standalone objects via trace/beauty/Build, exporting their > formatting functions via beauty.h and env.h. Switch arch_errno_names.o > and syscalltbl.o assignments directly to perf-util-y and add a top-level > recursive kbuild hook (perf-util-$(CONFIG_TRACE) += trace/beauty/) to > compile them into libperf-util.a, resolving remote linkage for standalone > python extensions. Does the description regarding perf-util-$(CONFIG_TRACE) match the code? The commit message mentions a conditional kbuild hook, but the patch below adds it unconditionally. > diff --git a/tools/perf/Build b/tools/perf/Build > --- a/tools/perf/Build > +++ b/tools/perf/Build > @@ -34,6 +34,8 @@ ifeq ($(CONFIG_LIBTRACEEVENT),y) > perf-$(CONFIG_TRACE) += trace/beauty/ > endif > > +perf-util-y += trace/beauty/ > + > perf-$(CONFIG_LIBELF) += builtin-probe.o Since this is an unconditional assignment to perf-util-y, could the commit message be clarified here, or was the assignment intended to be conditional on CONFIG_TRACE? -- Sashiko AI review · https://sashiko.dev/#/patchset/20260512053539.3410189-1-irogers@google.com?part=2 ^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v1 03/14] perf build: Decouple pmu-events from prepare umbrella target 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers 2026-05-12 5:35 ` [PATCH v1 01/14] bpftool build: Restrict feature tests during bootstrap compilation Ian Rogers 2026-05-12 5:35 ` [PATCH v1 02/14] perf trace beauty: Make beauty generated C code standalone .o files Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-12 5:35 ` [PATCH v1 04/14] perf build: Remove empty archheaders target Ian Rogers ` (11 subsequent siblings) 14 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers Currently, the $(LIBPMU_EVENTS_IN) sub-make depends on the massive "prepare" umbrella target. Because "prepare" depends on external libraries (libapi, libperf, etc.) as well as dozens of generated headers, make completely serializes the launch of the pmu-events sub-make behind some of those unrelated prerequisites. Since pmu-events is a large compilation unit, unblock its startup by binding it directly to only $(LIBPERF) instead of prepare. This allows background python generation scripts to overlap simultaneously with the rest of the build. Testing a parallel build (make -j28 clean all) shows improvements: Before: real 0m27.642s user 2m32.356s sys 0m26.683s After: real 0m22.254s user 2m32.810s sys 0m24.646s This reclaims over 5 full seconds of build latency (~19.5% overall reduction) by elevating average CPU concurrency from ~5.5 active cores up to ~8 active cores. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index c81797ceec42..c66af4c825fd 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -550,7 +550,7 @@ build := -f $(srctree)/tools/build/Makefile.build dir=. obj $(PERF_IN): prepare FORCE $(Q)$(MAKE) $(build)=perf -$(LIBPMU_EVENTS_IN): FORCE prepare +$(LIBPMU_EVENTS_IN): FORCE $(LIBPERF) $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events $(LIBPMU_EVENTS): $(LIBPMU_EVENTS_IN) -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v1 04/14] perf build: Remove empty archheaders target 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers ` (2 preceding siblings ...) 2026-05-12 5:35 ` [PATCH v1 03/14] perf build: Decouple pmu-events from prepare umbrella target Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-12 5:35 ` [PATCH v1 05/14] perf build: Move BPF skeleton generation out of Makefile.perf Ian Rogers ` (10 subsequent siblings) 14 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers Remove empty target that doesn't do anything. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index c66af4c825fd..24581941e912 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -627,7 +627,7 @@ endif __build-dir = $(subst $(OUTPUT),,$(dir $@)) build-dir = $(or $(__build-dir),.) -prepare: $(OUTPUT)PERF-VERSION-FILE archheaders \ +prepare: $(OUTPUT)PERF-VERSION-FILE \ arm64-sysreg-defs \ $(LIBAPI) \ $(LIBPERF) \ @@ -1070,7 +1070,7 @@ FORCE: .PHONY: all install clean config-clean strip install-gtk .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare -.PHONY: archheaders python_perf_target +.PHONY: python_perf_target endif # force_fixdep -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v1 05/14] perf build: Move BPF skeleton generation out of Makefile.perf 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers ` (3 preceding siblings ...) 2026-05-12 5:35 ` [PATCH v1 04/14] perf build: Remove empty archheaders target Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-12 5:35 ` [PATCH v1 06/14] perf build: Encapsulate vmlinux.h and bpftool in bpf_skel.mak Ian Rogers ` (9 subsequent siblings) 14 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers Currently, the top-level Makefile.perf defines a massive global bpf-skel umbrella target that pre-compiles all 12+ BPF skeletons (%.skel.h) upfront before launching sub-makes. This forces unrelated sub-makes to serialize behind bpftool and clang BPF target evaluations, causing parallel build bottlenecks. Furthermore, bench_uprobe.bpf.c lived inside util/bpf_skel/, breaking conceptual directory encapsulation since it is consumed purely by bench/uprobe.c. Refactor the BPF skeletons to better achieve directory isolation: 1. Move tools/perf/util/bpf_skel/bench_uprobe.bpf.c directly into tools/perf/bench/bpf_skel/. 2. Extract the skeleton generation infrastructure out of Makefile.perf into a shared inclusion file tools/perf/bpf_skel.mak. 3. Include bpf_skel.mak locally inside tools/perf/util/Build and tools/perf/bench/Build and bind precise local prerequisites. 4. Safely synchronize the shared bpftool bootstrap and vmlinux.h targets via the conditional prepare: umbrella to avoid parallel sub-make races, while evaluating the actual skeletons completely locally on demand. A later patch will move these targets into bpf_skel.mak. 5. Export CLANG from the global Makefile to ensure accurate tool propagation. 6. Clean up Makefile.perf by stripping the global bpf-skel umbrella target and its SKELETONS list. While removing code from Makefile.perf generally helps build performance, the impact here is minimal. The main motivation for the change is to better encapsulate things in the build and simplify Makefile.perf that has around 50 lines removed. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 59 ++----------------- tools/perf/bench/Build | 6 ++ .../bpf_skel/bench_uprobe.bpf.c | 0 tools/perf/bench/uprobe.c | 2 +- tools/perf/bpf_skel.mak | 55 +++++++++++++++++ tools/perf/util/Build | 15 ++++- 6 files changed, 80 insertions(+), 57 deletions(-) rename tools/perf/{util => bench}/bpf_skel/bench_uprobe.bpf.c (100%) create mode 100644 tools/perf/bpf_skel.mak diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 24581941e912..d4fc10f36781 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -274,7 +274,7 @@ ifeq ($(PYLINT),1) PYLINT := $(shell which pylint 2> /dev/null) endif -export srctree OUTPUT RM CC CXX RUSTC LD AR CFLAGS CXXFLAGS RUST_FLAGS V BISON FLEX AWK +export srctree OUTPUT RM CC CXX RUSTC CLANG LD AR CFLAGS CXXFLAGS RUST_FLAGS V BISON FLEX AWK LIBBPF export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT include $(srctree)/tools/build/Makefile.include @@ -632,8 +632,7 @@ prepare: $(OUTPUT)PERF-VERSION-FILE \ $(LIBAPI) \ $(LIBPERF) \ $(LIBSUBCMD) \ - $(LIBSYMBOL) \ - bpf-skel + $(LIBSYMBOL) ifdef LIBBPF_STATIC prepare: $(LIBBPF) @@ -914,44 +913,13 @@ python-clean: SKEL_OUT := $(abspath $(OUTPUT)util/bpf_skel) SKEL_TMP_OUT := $(abspath $(SKEL_OUT)/.tmp) -SKELETONS := $(SKEL_OUT)/bpf_prog_profiler.skel.h -SKELETONS += $(SKEL_OUT)/bperf_leader.skel.h $(SKEL_OUT)/bperf_follower.skel.h -SKELETONS += $(SKEL_OUT)/bperf_cgroup.skel.h $(SKEL_OUT)/func_latency.skel.h -SKELETONS += $(SKEL_OUT)/off_cpu.skel.h $(SKEL_OUT)/lock_contention.skel.h -SKELETONS += $(SKEL_OUT)/kwork_trace.skel.h $(SKEL_OUT)/sample_filter.skel.h -SKELETONS += $(SKEL_OUT)/kwork_top.skel.h $(SKEL_OUT)/syscall_summary.skel.h -SKELETONS += $(SKEL_OUT)/bench_uprobe.skel.h -SKELETONS += $(SKEL_OUT)/augmented_raw_syscalls.skel.h $(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT): $(Q)$(MKDIR) -p $@ ifeq ($(CONFIG_PERF_BPF_SKEL),y) +prepare: $(BPFTOOL) $(SKEL_OUT)/vmlinux.h BPFTOOL := $(SKEL_TMP_OUT)/bootstrap/bpftool -# Get Clang's default includes on this system, as opposed to those seen by -# '--target=bpf'. This fixes "missing" files on some architectures/distros, -# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc. -# -# Use '-idirafter': Don't interfere with include mechanics except where the -# build would have failed anyways. -define get_sys_includes -$(shell $(1) $(2) -v -E - </dev/null 2>&1 \ - | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ -$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') -endef - -ifneq ($(CROSS_COMPILE),) -CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%)) -endif - -CLANG_OPTIONS = -Wall -CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) -BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES) -TOOLS_UAPI_INCLUDE := -I$(srctree)/tools/include/uapi - -ifneq ($(WERROR),0) - CLANG_OPTIONS += -Werror -endif $(BPFTOOL): | $(SKEL_TMP_OUT) $(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool \ @@ -993,29 +961,10 @@ else $(Q)cp "$(VMLINUX_H)" $@ endif -$(SKEL_TMP_OUT)/%.bpf.o: $(OUTPUT)PERF-VERSION-FILE util/bpf_skel/perf_version.h | $(SKEL_TMP_OUT) -$(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h - $(QUIET_CLANG)$(CLANG) -g -O2 -fno-stack-protector --target=bpf \ - $(CLANG_OPTIONS) $(EXTRA_BPF_FLAGS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \ - -include $(OUTPUT)PERF-VERSION-FILE -include util/bpf_skel/perf_version.h \ - -fms-extensions -Wno-microsoft-anon-tag \ - -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@ - -$(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o | $(BPFTOOL) - $(QUIET_GENSKEL)$(BPFTOOL) gen skeleton $< > $@ - -bpf-skel: $(SKELETONS) - -.PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o - -else # CONFIG_PERF_BPF_SKEL - -bpf-skel: - endif # CONFIG_PERF_BPF_SKEL bpf-skel-clean: - $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS) $(SKEL_OUT)/vmlinux.h + $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKEL_OUT)/*.skel.h $(SKEL_OUT)/vmlinux.h $(OUTPUT)bench/bpf_skel/*.skel.h pmu-events-clean: ifeq ($(OUTPUT),) diff --git a/tools/perf/bench/Build b/tools/perf/bench/Build index b558ab98719f..67b76fe20ba6 100644 --- a/tools/perf/bench/Build +++ b/tools/perf/bench/Build @@ -24,3 +24,9 @@ perf-bench-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o perf-bench-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o perf-bench-$(CONFIG_NUMA) += numa.o + +ifeq ($(CONFIG_PERF_BPF_SKEL),y) +include $(srctree)/tools/perf/bpf_skel.mak + +$(OUTPUT)bench/uprobe.o: $(SKEL_OUT)/bench_uprobe.skel.h +endif diff --git a/tools/perf/util/bpf_skel/bench_uprobe.bpf.c b/tools/perf/bench/bpf_skel/bench_uprobe.bpf.c similarity index 100% rename from tools/perf/util/bpf_skel/bench_uprobe.bpf.c rename to tools/perf/bench/bpf_skel/bench_uprobe.bpf.c diff --git a/tools/perf/bench/uprobe.c b/tools/perf/bench/uprobe.c index 89697ff788ef..616873bca243 100644 --- a/tools/perf/bench/uprobe.c +++ b/tools/perf/bench/uprobe.c @@ -44,7 +44,7 @@ static const char * const bench_uprobe_usage[] = { }; #ifdef HAVE_BPF_SKEL -#include "bpf_skel/bench_uprobe.skel.h" +#include "bench/bpf_skel/bench_uprobe.skel.h" #define bench_uprobe__attach_uprobe(prog) \ skel->links.prog = bpf_program__attach_uprobe_opts(/*prog=*/skel->progs.prog, \ diff --git a/tools/perf/bpf_skel.mak b/tools/perf/bpf_skel.mak new file mode 100644 index 000000000000..bcb704d5af32 --- /dev/null +++ b/tools/perf/bpf_skel.mak @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: GPL-2.0 +# Shared BPF Skeleton Generator Rules + +include $(srctree)/tools/scripts/Makefile.include + +# Shared foundational tooling always lives in util/bpf_skel +SKEL_TOOL_OUT := $(abspath $(OUTPUT)util/bpf_skel) +SKEL_TOOL_TMP_OUT := $(abspath $(SKEL_TOOL_OUT)/.tmp) + +# Component specific output lives in $(dir)/bpf_skel +SKEL_OUT := $(abspath $(OUTPUT)$(dir)/bpf_skel) +SKEL_TMP_OUT := $(abspath $(SKEL_OUT)/.tmp) + +ifeq ($(CONFIG_PERF_BPF_SKEL),y) +BPFTOOL := $(SKEL_TOOL_TMP_OUT)/bootstrap/bpftool +VMLINUX_H := $(SKEL_TOOL_OUT)/vmlinux.h +bpf_skel_deps := $(BPFTOOL) $(VMLINUX_H) + +define get_sys_includes +$(shell $(1) $(2) -v -E - </dev/null 2>&1 \ + | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ +$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') +endef + +ifneq ($(CROSS_COMPILE),) +CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%)) +endif + +CLANG_OPTIONS = -Wall +CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) +LIBBPF_INCLUDE := $(abspath $(or $(OUTPUT),.))/libbpf/include +BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(SKEL_TOOL_OUT) -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES) +TOOLS_UAPI_INCLUDE := -I$(srctree)/tools/include/uapi + +ifneq ($(WERROR),0) + CLANG_OPTIONS += -Werror +endif + +# Consolidated Pattern rule for $(dir)/bpf_skel/ +$(SKEL_TMP_OUT)/%.bpf.o: $(srctree)/tools/perf/$(dir)/bpf_skel/%.bpf.c $(LIBBPF) $(VMLINUX_H) $(OUTPUT)PERF-VERSION-FILE util/bpf_skel/perf_version.h + $(call rule_mkdir) + $(QUIET_CLANG) + $(Q)$(CLANG) -g -O2 -fno-stack-protector --target=bpf \ + $(CLANG_OPTIONS) $(EXTRA_BPF_FLAGS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \ + -include $(OUTPUT)PERF-VERSION-FILE -include util/bpf_skel/perf_version.h \ + -fms-extensions -Wno-microsoft-anon-tag \ + -c $< -o $@ + +$(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o $(BPFTOOL) + $(call rule_mkdir) + $(QUIET_GENSKEL) + $(Q)$(BPFTOOL) gen skeleton $< > $@ + +.PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o +endif # CONFIG_PERF_BPF_SKEL diff --git a/tools/perf/util/Build b/tools/perf/util/Build index abc9a2926e85..40c258ac99b9 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -442,4 +442,17 @@ $(OUTPUT)%.pylint_log: % perf-util-y += $(PYLINT_TEST_LOGS) - +ifeq ($(CONFIG_PERF_BPF_SKEL),y) +include $(srctree)/tools/perf/bpf_skel.mak + +$(OUTPUT)util/bpf_ftrace.o: $(SKEL_OUT)/func_latency.skel.h +$(OUTPUT)util/bpf-filter.o: $(SKEL_OUT)/sample_filter.skel.h +$(OUTPUT)util/bpf_kwork_top.o: $(SKEL_OUT)/kwork_top.skel.h +$(OUTPUT)util/bpf_off_cpu.o: $(SKEL_OUT)/off_cpu.skel.h +$(OUTPUT)util/bpf-trace-summary.o: $(SKEL_OUT)/syscall_summary.skel.h +$(OUTPUT)util/bpf_counter_cgroup.o: $(SKEL_OUT)/bperf_cgroup.skel.h +$(OUTPUT)util/bpf_trace_augment.o: $(SKEL_OUT)/augmented_raw_syscalls.skel.h +$(OUTPUT)util/bpf_counter.o: $(SKEL_OUT)/bpf_prog_profiler.skel.h $(SKEL_OUT)/bperf_leader.skel.h $(SKEL_OUT)/bperf_follower.skel.h +$(OUTPUT)util/bpf_lock_contention.o: $(SKEL_OUT)/lock_contention.skel.h +$(OUTPUT)util/bpf_kwork.o: $(SKEL_OUT)/kwork_trace.skel.h +endif -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v1 06/14] perf build: Encapsulate vmlinux.h and bpftool in bpf_skel.mak 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers ` (4 preceding siblings ...) 2026-05-12 5:35 ` [PATCH v1 05/14] perf build: Move BPF skeleton generation out of Makefile.perf Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-12 5:35 ` [PATCH v1 07/14] perf build: Move static libbpf dependency out of prepare step Ian Rogers ` (8 subsequent siblings) 14 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers Currently, bpftool and vmlinux.h are prerequisites of the top-level prepare target in Makefile.perf. This unnecessarily blocks the massive parallel C compilation of libraries (perf-util, perf-ui, pmu-events) during the initial startup phase. Move all bpftool and vmlinux.h generation rules down into tools/perf/bpf_skel.mak to encapsulate BPF tooling completely within the skeleton framework. Remove them entirely from prepare to unblock immediate parallel build execution. To prevent parallel sub-makes (perf-util and perf-bench) from racing to build shared prerequisites concurrently, while maintaining strict directory encapsulation without top-level inclusions, serialize bench after the util static archive finishes using an order-only prerequisite: $(LIBPERF_BENCH_IN): FORCE prepare | $(LIBPERF_UTIL) Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.config | 2 +- tools/perf/Makefile.perf | 61 +++++--------------------------------- tools/perf/bpf_skel.mak | 47 +++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 06d7a3f9990c..bc1111c88226 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -736,7 +736,7 @@ ifeq ($(BUILD_BPF_SKEL),1) endif ifndef GEN_VMLINUX_H - VMLINUX_H=$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h + VMLINUX_H_FILE=$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h endif dwarf-post-unwind := 1 diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index d4fc10f36781..ec0e91bedce1 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -274,7 +274,7 @@ ifeq ($(PYLINT),1) PYLINT := $(shell which pylint 2> /dev/null) endif -export srctree OUTPUT RM CC CXX RUSTC CLANG LD AR CFLAGS CXXFLAGS RUST_FLAGS V BISON FLEX AWK LIBBPF +export srctree OUTPUT RM CC CXX RUSTC CLANG LD AR CFLAGS CXXFLAGS RUST_FLAGS V BISON FLEX AWK LIBBPF READELF export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT include $(srctree)/tools/build/Makefile.include @@ -324,7 +324,7 @@ else FEATURE_DUMP_EXPORT := $(realpath $(FEATURES_DUMP)) endif -export prefix bindir sharedir sysconfdir DESTDIR +export prefix bindir sharedir sysconfdir DESTDIR VMLINUX_H_FILE # sparse is architecture-neutral, which means that we need to tell it # explicitly what architecture to check for. Fix this up for yours.. @@ -556,7 +556,9 @@ $(LIBPMU_EVENTS_IN): FORCE $(LIBPERF) $(LIBPMU_EVENTS): $(LIBPMU_EVENTS_IN) $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $< -$(LIBPERF_BENCH_IN): FORCE prepare +# The $(LIBPERF_UTIL) dependency is to ensure bpftool and vmlinux.h +# aren't racily built for bench/bpf_skel/bench_uprobe.bpf.c +$(LIBPERF_BENCH_IN): FORCE prepare | $(LIBPERF_UTIL) $(Q)$(MAKE) $(build)=perf-bench $(LIBPERF_BENCH): $(LIBPERF_BENCH_IN) @@ -911,60 +913,11 @@ $(INSTALL_DOC_TARGETS): python-clean: $(python-clean) -SKEL_OUT := $(abspath $(OUTPUT)util/bpf_skel) -SKEL_TMP_OUT := $(abspath $(SKEL_OUT)/.tmp) - -$(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT): +$(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT): $(Q)$(MKDIR) -p $@ -ifeq ($(CONFIG_PERF_BPF_SKEL),y) -prepare: $(BPFTOOL) $(SKEL_OUT)/vmlinux.h -BPFTOOL := $(SKEL_TMP_OUT)/bootstrap/bpftool - -$(BPFTOOL): | $(SKEL_TMP_OUT) - $(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool \ - OUTPUT=$(SKEL_TMP_OUT)/ bootstrap - -# Paths to search for a kernel to generate vmlinux.h from. -VMLINUX_BTF_ELF_PATHS ?= $(if $(O),$(O)/vmlinux) \ - $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \ - ../../vmlinux \ - /boot/vmlinux-$(shell uname -r) - -# Paths to BTF information. -VMLINUX_BTF_BTF_PATHS ?= /sys/kernel/btf/vmlinux - -# Filter out kernels that don't exist or without a BTF section. -VMLINUX_BTF_ELF_ABSPATHS ?= $(abspath $(wildcard $(VMLINUX_BTF_ELF_PATHS))) -VMLINUX_BTF_PATHS ?= $(shell for file in $(VMLINUX_BTF_ELF_ABSPATHS); \ - do \ - if [ -f $$file ] && ($(READELF) -S "$$file" | grep -q .BTF); \ - then \ - echo "$$file"; \ - fi; \ - done) \ - $(wildcard $(VMLINUX_BTF_BTF_PATHS)) - -# Select the first as the source of vmlinux.h. -VMLINUX_BTF ?= $(firstword $(VMLINUX_BTF_PATHS)) - -ifeq ($(VMLINUX_H),) - ifeq ($(VMLINUX_BTF),) - $(error Missing bpftool input for generating vmlinux.h) - endif -endif - -$(SKEL_OUT)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) $(VMLINUX_H) -ifeq ($(VMLINUX_H),) - $(QUIET_GEN)$(BPFTOOL) btf dump file $< format c > $@ -else - $(Q)cp "$(VMLINUX_H)" $@ -endif - -endif # CONFIG_PERF_BPF_SKEL - bpf-skel-clean: - $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKEL_OUT)/*.skel.h $(SKEL_OUT)/vmlinux.h $(OUTPUT)bench/bpf_skel/*.skel.h + $(Q)$(MAKE) -f bpf_skel.mak clean pmu-events-clean: ifeq ($(OUTPUT),) diff --git a/tools/perf/bpf_skel.mak b/tools/perf/bpf_skel.mak index bcb704d5af32..ded578b9570c 100644 --- a/tools/perf/bpf_skel.mak +++ b/tools/perf/bpf_skel.mak @@ -36,6 +36,47 @@ ifneq ($(WERROR),0) CLANG_OPTIONS += -Werror endif +$(BPFTOOL): + $(Q)mkdir -p $(SKEL_TOOL_TMP_OUT) + $(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool OUTPUT=$(SKEL_TOOL_TMP_OUT)/ bootstrap + +# Paths to search for a kernel to generate vmlinux.h from. +VMLINUX_BTF_ELF_PATHS ?= $(if $(O),$(O)/vmlinux) \ + $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \ + ../../vmlinux \ + /boot/vmlinux-$(shell uname -r) + +# Paths to BTF information. +VMLINUX_BTF_BTF_PATHS ?= /sys/kernel/btf/vmlinux + +# Filter out kernels that don't exist or without a BTF section. +VMLINUX_BTF_ELF_ABSPATHS ?= $(abspath $(wildcard $(VMLINUX_BTF_ELF_PATHS))) +VMLINUX_BTF_PATHS ?= $(shell for file in $(VMLINUX_BTF_ELF_ABSPATHS); \ + do \ + if [ -f $$file ] && ($(READELF) -S "$$file" | grep -q .BTF); \ + then \ + echo "$$file"; \ + fi; \ + done) \ + $(wildcard $(VMLINUX_BTF_BTF_PATHS)) + +# Select the first as the source of vmlinux.h. +VMLINUX_BTF ?= $(firstword $(VMLINUX_BTF_PATHS)) + +ifeq ($(VMLINUX_H_FILE),) + ifeq ($(VMLINUX_BTF),) + $(error Missing bpftool input for generating vmlinux.h) + endif +endif + +$(VMLINUX_H): $(VMLINUX_BTF) $(BPFTOOL) $(VMLINUX_H_FILE) + $(call rule_mkdir) +ifeq ($(VMLINUX_H_FILE),) + $(QUIET_GEN)$(BPFTOOL) btf dump file $< format c > $@ +else + $(Q)cp "$(VMLINUX_H_FILE)" $@ +endif + # Consolidated Pattern rule for $(dir)/bpf_skel/ $(SKEL_TMP_OUT)/%.bpf.o: $(srctree)/tools/perf/$(dir)/bpf_skel/%.bpf.c $(LIBBPF) $(VMLINUX_H) $(OUTPUT)PERF-VERSION-FILE util/bpf_skel/perf_version.h $(call rule_mkdir) @@ -52,4 +93,10 @@ $(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o $(BPFTOOL) $(Q)$(BPFTOOL) gen skeleton $< > $@ .PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o + endif # CONFIG_PERF_BPF_SKEL + +clean: + $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TOOL_TMP_OUT) $(OUTPUT)bench/bpf_skel/.tmp $(SKEL_TOOL_OUT)/*.skel.h $(OUTPUT)bench/bpf_skel/*.skel.h $(SKEL_TOOL_OUT)/vmlinux.h + +.PHONY: clean -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v1 07/14] perf build: Move static libbpf dependency out of prepare step 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers ` (5 preceding siblings ...) 2026-05-12 5:35 ` [PATCH v1 06/14] perf build: Encapsulate vmlinux.h and bpftool in bpf_skel.mak Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-12 5:35 ` [PATCH v1 08/14] perf build: Pre-generate BPF skeletons during umbrella prepare phase Ian Rogers ` (7 subsequent siblings) 14 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers The prepare step is a large serialization point before parallel sub-makes build the perf tool. The libbpf headers are used in the bench and util libraries, as well as individual perf builtin commands. Move the libbpf dependency out of the prepare step and into the dependencies for those targets to avoid it being a source of serialization in the prepare step. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index ec0e91bedce1..5af767415c11 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -547,7 +547,7 @@ export NO_JEVENTS build := -f $(srctree)/tools/build/Makefile.build dir=. obj -$(PERF_IN): prepare FORCE +$(PERF_IN): prepare $(LIBBPF) FORCE $(Q)$(MAKE) $(build)=perf $(LIBPMU_EVENTS_IN): FORCE $(LIBPERF) @@ -558,7 +558,7 @@ $(LIBPMU_EVENTS): $(LIBPMU_EVENTS_IN) # The $(LIBPERF_UTIL) dependency is to ensure bpftool and vmlinux.h # aren't racily built for bench/bpf_skel/bench_uprobe.bpf.c -$(LIBPERF_BENCH_IN): FORCE prepare | $(LIBPERF_UTIL) +$(LIBPERF_BENCH_IN): FORCE prepare $(LIBBPF) | $(LIBPERF_UTIL) $(Q)$(MAKE) $(build)=perf-bench $(LIBPERF_BENCH): $(LIBPERF_BENCH_IN) @@ -576,7 +576,7 @@ $(LIBPERF_UI_IN): FORCE prepare $(LIBPERF_UI): $(LIBPERF_UI_IN) $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $< -$(LIBPERF_UTIL_IN): FORCE prepare +$(LIBPERF_UTIL_IN): FORCE prepare $(LIBBPF) $(Q)$(MAKE) $(build)=perf-util $(LIBPERF_UTIL): $(LIBPERF_UTIL_IN) @@ -636,10 +636,6 @@ prepare: $(OUTPUT)PERF-VERSION-FILE \ $(LIBSUBCMD) \ $(LIBSYMBOL) -ifdef LIBBPF_STATIC -prepare: $(LIBBPF) -endif - $(OUTPUT)%.o: %.c prepare FORCE $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v1 08/14] perf build: Pre-generate BPF skeletons during umbrella prepare phase 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers ` (6 preceding siblings ...) 2026-05-12 5:35 ` [PATCH v1 07/14] perf build: Move static libbpf dependency out of prepare step Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-12 5:35 ` [PATCH v1 09/14] perf build: Move libsymbol dependency out of prepare step Ian Rogers ` (6 subsequent siblings) 14 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers Currently, BPF skeleton generation rules (bpf_skel.mak) are evaluated as part of util/Build. However, because LIBPERF_UTIL_IN explicitly depends on the top-level static libbpf archive, Make completely blocked the execution of bpftool bootstrap and skeleton generation until libbpf finished compiling midway through the build. Since bpftool bootstrap compiles its own independent copy of libbpf.a, it does not depend on the top-level libbpf target. Decouple early skeleton tooling generation by attaching bpf-skel-prepare to the umbrella prepare target, exporting CONFIG_PERF_BPF_SKEL to ensure accurate feature propagation. This allows Make to compile bpftool and dump vmlinux.h in the background at build startup, eliminating the initial sub-make startup bottleneck before BPF object compilation while keeping 100% of tooling rules perfectly encapsulated in bpf_skel.mak. Provide an empty fallback target to ensure builds succeed when BPF skeletons are disabled. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 6 +++++- tools/perf/bpf_skel.mak | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 5af767415c11..df68d29ecab7 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -275,7 +275,7 @@ ifeq ($(PYLINT),1) endif export srctree OUTPUT RM CC CXX RUSTC CLANG LD AR CFLAGS CXXFLAGS RUST_FLAGS V BISON FLEX AWK LIBBPF READELF -export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT +export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT CONFIG_PERF_BPF_SKEL include $(srctree)/tools/build/Makefile.include @@ -629,8 +629,12 @@ endif __build-dir = $(subst $(OUTPUT),,$(dir $@)) build-dir = $(or $(__build-dir),.) +bpf-skel-prepare: + $(Q)$(MAKE) -f bpf_skel.mak bpf-skel-prepare + prepare: $(OUTPUT)PERF-VERSION-FILE \ arm64-sysreg-defs \ + bpf-skel-prepare \ $(LIBAPI) \ $(LIBPERF) \ $(LIBSUBCMD) \ diff --git a/tools/perf/bpf_skel.mak b/tools/perf/bpf_skel.mak index ded578b9570c..c4340a218323 100644 --- a/tools/perf/bpf_skel.mak +++ b/tools/perf/bpf_skel.mak @@ -16,6 +16,10 @@ BPFTOOL := $(SKEL_TOOL_TMP_OUT)/bootstrap/bpftool VMLINUX_H := $(SKEL_TOOL_OUT)/vmlinux.h bpf_skel_deps := $(BPFTOOL) $(VMLINUX_H) +.PHONY: bpf-skel-prepare +bpf-skel-prepare: $(bpf_skel_deps) + @: + define get_sys_includes $(shell $(1) $(2) -v -E - </dev/null 2>&1 \ | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ @@ -94,6 +98,10 @@ $(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o $(BPFTOOL) .PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o +else # CONFIG_PERF_BPF_SKEL +.PHONY: bpf-skel-prepare +bpf-skel-prepare: + @: endif # CONFIG_PERF_BPF_SKEL clean: -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v1 09/14] perf build: Move libsymbol dependency out of prepare step 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers ` (7 preceding siblings ...) 2026-05-12 5:35 ` [PATCH v1 08/14] perf build: Pre-generate BPF skeletons during umbrella prepare phase Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-12 5:35 ` [PATCH v1 10/14] perf build: Remove redundant libbpf feature check for static builds Ian Rogers ` (5 subsequent siblings) 14 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers The prepare step is a large serialization point before parallel sub-makes build the perf tool. The libsymbol headers are used in the bench and util libraries. Move the libsymbol dependency out of the prepare step and into the dependencies for those targets to avoid it being a source of serialization in the prepare step. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index df68d29ecab7..d2e673d5e5be 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -558,7 +558,7 @@ $(LIBPMU_EVENTS): $(LIBPMU_EVENTS_IN) # The $(LIBPERF_UTIL) dependency is to ensure bpftool and vmlinux.h # aren't racily built for bench/bpf_skel/bench_uprobe.bpf.c -$(LIBPERF_BENCH_IN): FORCE prepare $(LIBBPF) | $(LIBPERF_UTIL) +$(LIBPERF_BENCH_IN): FORCE prepare $(LIBBPF) $(LIBSYMBOL) | $(LIBPERF_UTIL) $(Q)$(MAKE) $(build)=perf-bench $(LIBPERF_BENCH): $(LIBPERF_BENCH_IN) @@ -576,7 +576,7 @@ $(LIBPERF_UI_IN): FORCE prepare $(LIBPERF_UI): $(LIBPERF_UI_IN) $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $< -$(LIBPERF_UTIL_IN): FORCE prepare $(LIBBPF) +$(LIBPERF_UTIL_IN): FORCE prepare $(LIBBPF) $(LIBSYMBOL) $(Q)$(MAKE) $(build)=perf-util $(LIBPERF_UTIL): $(LIBPERF_UTIL_IN) @@ -637,8 +637,7 @@ prepare: $(OUTPUT)PERF-VERSION-FILE \ bpf-skel-prepare \ $(LIBAPI) \ $(LIBPERF) \ - $(LIBSUBCMD) \ - $(LIBSYMBOL) + $(LIBSUBCMD) $(OUTPUT)%.o: %.c prepare FORCE $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v1 10/14] perf build: Remove redundant libbpf feature check for static builds 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers ` (8 preceding siblings ...) 2026-05-12 5:35 ` [PATCH v1 09/14] perf build: Move libsymbol dependency out of prepare step Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-12 5:35 ` [PATCH v1 11/14] tools build: Integrate libdebuginfod into test-all fast path Ian Rogers ` (4 subsequent siblings) 14 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers By default, the perf tool compiles and statically links against its own internal copy of libbpf (tools/lib/bpf/libbpf.a), setting LIBBPF_STATIC=1. Despite this static linkage, Makefile.config unconditionally executed $(call feature_check,libbpf), which forced a synchronous sub-make fork during AST parsing to detect dynamic system libbpf libraries. As noted in the internal Makefile comments, this check was executed purely so that running `make VF=1` would display the detection status of system libbpf. During standard builds without LIBBPF_DYNAMIC=1, the detection result was entirely ignored. Wrap the libbpf feature check inside LIBBPF_DYNAMIC=1 so Make avoids the redundant sub-make fork overhead during standard static builds. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.config | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index bc1111c88226..fbe7fa83b0bb 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -587,10 +587,8 @@ ifndef NO_LIBELF ifndef NO_LIBBPF ifeq ($(feature-bpf), 1) - # detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status - $(call feature_check,libbpf) - ifdef LIBBPF_DYNAMIC + $(call feature_check,libbpf) ifeq ($(feature-libbpf), 1) EXTLIBS += -lbpf CFLAGS += -DHAVE_LIBBPF_SUPPORT -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v1 11/14] tools build: Integrate libdebuginfod into test-all fast path 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers ` (9 preceding siblings ...) 2026-05-12 5:35 ` [PATCH v1 10/14] perf build: Remove redundant libbpf feature check for static builds Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-12 5:35 ` [PATCH v1 12/14] perf pmu-events: Split big_c_string storage into standalone compilation unit Ian Rogers ` (3 subsequent siblings) 14 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers Bundling libdebuginfod into test-all.c allows Make to avoid an individual feature check sub-make fork during AST parsing. Short-circuit feature_check in Makefile.feature to instantly skip sub-make evaluations when a feature was already pre-detected by test-all. Trade-offs: On some Linux distributions (e.g., Debian/Ubuntu), libdebuginfod-dev is packaged separately from libelf-dev and libdw-dev. If a user installs libdw-dev but omits libdebuginfod-dev, adding -ldebuginfod to BUILD_ALL causes test-all to fail, falling back to individual feature tests. However, on fully configured developer workstations, this successfully reclaims sequential startup latency. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/build/Makefile.feature | 6 ++++-- tools/build/feature/Makefile | 2 +- tools/build/feature/test-all.c | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index 2f192d3bf61b..d8febe5d5800 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature @@ -8,7 +8,9 @@ endif feature_check = $(eval $(feature_check_code)) define feature_check_code - feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC="$(CC)" CXX="$(CXX)" CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) + ifeq ($(feature-$(1)),) + feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC="$(CC)" CXX="$(CXX)" CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) + endif endef feature_set = $(eval $(feature_set_code)) @@ -100,6 +102,7 @@ FEATURE_TESTS_BASIC := \ disassembler-four-args \ disassembler-init-styled \ file-handle \ + libdebuginfod \ libopenssl # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list @@ -125,7 +128,6 @@ FEATURE_TESTS_EXTRA := \ clang \ libbpf \ libpfm4 \ - libdebuginfod \ clang-bpf-co-re \ bpftool-skeletons diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 704c687ed3ad..dc828523b50a 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -115,7 +115,7 @@ __BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $( BUILD_BFD = $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang \ $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -ldl -lz -llzma -lzstd \ - $(shell $(PKG_CONFIG) --libs --cflags openssl 2>/dev/null) + $(shell $(PKG_CONFIG) --libs --cflags openssl 2>/dev/null) -ldebuginfod __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS) BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1 diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c index 1488bf6e6078..b6984236859f 100644 --- a/tools/build/feature/test-all.c +++ b/tools/build/feature/test-all.c @@ -146,6 +146,10 @@ # include "test-libopenssl.c" #undef main +#define main main_test_libdebuginfod +# include "test-libdebuginfod.c" +#undef main + int main(int argc, char *argv[]) { main_test_libpython(); @@ -178,6 +182,7 @@ int main(int argc, char *argv[]) main_test_libzstd(); main_test_libtraceevent(); main_test_libopenssl(); + main_test_libdebuginfod(); return 0; } -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v1 12/14] perf pmu-events: Split big_c_string storage into standalone compilation unit 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers ` (10 preceding siblings ...) 2026-05-12 5:35 ` [PATCH v1 11/14] tools build: Integrate libdebuginfod into test-all fast path Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-12 5:35 ` [PATCH v1 13/14] perf pmu-events: Parallelize JSON and metric pre-computation in jevents.py Ian Rogers ` (2 subsequent siblings) 14 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers Currently, jevents.py emits both the massive 2.8 MB big_c_string literal and tens of thousands of compact_pmu_event struct arrays into a single pmu-events.c compilation unit. Compiling this giant file takes ~2.2 seconds on a single CPU core during Kbuild startup. Refactor jevents.py to emit big_c_string into a dedicated pmu-events-string.c compilation unit. This allows Kbuild to compile pmu-events.o and pmu-events-string.o simultaneously in parallel across two separate CPU cores, preserving 100% string deduplication and zero dynamic ELF relocations while cutting C compilation latency in half. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 4 ++-- tools/perf/pmu-events/Build | 15 ++++++++++++++- tools/perf/pmu-events/jevents.py | 20 ++++++++++++++++---- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index d2e673d5e5be..98b6f9fda8d1 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -921,7 +921,7 @@ bpf-skel-clean: pmu-events-clean: ifeq ($(OUTPUT),) $(call QUIET_CLEAN, pmu-events) $(RM) \ - pmu-events/pmu-events.c \ + pmu-events/pmu-events*.c \ pmu-events/metric_test.log \ pmu-events/test-empty-pmu-events.c \ pmu-events/empty-pmu-events.log @@ -929,7 +929,7 @@ ifeq ($(OUTPUT),) -name 'extra-metricgroups.json' -delete else # When an OUTPUT directory is present, clean up the copied pmu-events/arch directory. $(call QUIET_CLEAN, pmu-events) $(RM) -r $(OUTPUT)pmu-events/arch \ - $(OUTPUT)pmu-events/pmu-events.c \ + $(OUTPUT)pmu-events/pmu-events*.c \ $(OUTPUT)pmu-events/metric_test.log \ $(OUTPUT)pmu-events/test-empty-pmu-events.c \ $(OUTPUT)pmu-events/empty-pmu-events.log diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build index dc1df2d57ddc..f8f5ec7daa5f 100644 --- a/tools/perf/pmu-events/Build +++ b/tools/perf/pmu-events/Build @@ -1,7 +1,13 @@ EMPTY_PMU_EVENTS_C = pmu-events/empty-pmu-events.c # pmu-events.c will be generated by jevents.py or copied from EMPTY_PMU_EVENTS_C PMU_EVENTS_C = $(OUTPUT)pmu-events/pmu-events.c +PMU_EVENTS_STRING_C = $(OUTPUT)pmu-events/pmu-events-string.c + +ifeq ($(NO_JEVENTS),1) pmu-events-y += pmu-events.o +else +pmu-events-y += pmu-events.o pmu-events-string.o +endif # pmu-events.c file is generated in the OUTPUT directory so it needs a # separate rule to depend on it properly @@ -9,6 +15,10 @@ $(OUTPUT)pmu-events/pmu-events.o: $(PMU_EVENTS_C) $(call rule_mkdir) $(call if_changed_dep,cc_o_c) +$(OUTPUT)pmu-events/pmu-events-string.o: $(PMU_EVENTS_STRING_C) + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c) + # Message for $(call echo-cmd,cp), possibly remove the src file from # the destination to save space in the build log. quiet_cmd_cp = COPY $(patsubst %$<,%,$@) <- $< @@ -224,6 +234,9 @@ endif # and inputs are dependencies. $(PMU_EVENTS_C): $(JEVENTS_DEPS) $(call rule_mkdir) - $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) $(OUT_DIR) $@ + $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) $(OUT_DIR) $@ $(PMU_EVENTS_STRING_C) + +$(PMU_EVENTS_STRING_C): $(PMU_EVENTS_C) + @: endif # ifeq ($(NO_JEVENTS),1) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 3a1bcdcdc685..70a45e62f5d1 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -1422,6 +1422,8 @@ such as "arm/cortex-a34".''', ) ap.add_argument( 'output_file', type=argparse.FileType('w', encoding='utf-8'), nargs='?', default=sys.stdout) + ap.add_argument( + 'output_string_file', type=argparse.FileType('w', encoding='utf-8'), nargs='?', default=None) _args = ap.parse_args() _args.output_file.write(f""" @@ -1463,10 +1465,20 @@ struct pmu_table_entry { ftw(arch_path, [], preprocess_one_file) _bcs.compute() - _args.output_file.write('static const char *const big_c_string =\n') - for s in _bcs.big_string: - _args.output_file.write(s) - _args.output_file.write(';\n\n') + if not _args.output_string_file: + _args.output_file.write('static const char *const big_c_string =\n') + for s in _bcs.big_string: + _args.output_file.write(s) + _args.output_file.write(';\n\n') + else: + _args.output_string_file.write('/* SPDX-License-Identifier: GPL-2.0 */\n') + _args.output_string_file.write('/* Autogenerated by jevents.py */\n') + _args.output_string_file.write('const char big_c_string[] =\n') + for s in _bcs.big_string: + _args.output_string_file.write(s) + _args.output_string_file.write(';\n') + _args.output_string_file.close() + _args.output_file.write('extern const char big_c_string[];\n\n') for arch in archs: arch_path = f'{_args.starting_dir}/{arch}' ftw(arch_path, [], process_one_file) -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v1 13/14] perf pmu-events: Parallelize JSON and metric pre-computation in jevents.py 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers ` (11 preceding siblings ...) 2026-05-12 5:35 ` [PATCH v1 12/14] perf pmu-events: Split big_c_string storage into standalone compilation unit Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-12 5:35 ` [PATCH v1 14/14] perf build: Prefix SCRIPTS with output directory to fix continuous rebuilds Ian Rogers 2026-05-12 9:36 ` [PATCH v1 00/14] perf build: Reduce build time by one third James Clark 14 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers Currently, jevents.py parses hundreds of JSON event and metric files sequentially across all CPU architectures during Kbuild startup, taking ~3.3 seconds of pure single-core execution time. Refactor jevents.py to pre-populate its internal JSON AST cache in parallel across all available CPU cores using ProcessPoolExecutor. Configure worker process initializers to guarantee standard event mapping inheritance under spawn multiprocessing semantics, and apply depth filtering to prevent redundant worker tasks. This accelerates jevents.py execution by over 11x (from 3.3s down to ~290ms), fully reclaiming multi-core concurrency during the build generation phase. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/pmu-events/jevents.py | 36 ++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 70a45e62f5d1..eb72c154f946 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -457,8 +457,8 @@ class JsonEvent: return f'{{ { _bcs.offsets[s] } }}, /* {fix_comment(s)} */\n' -@lru_cache(maxsize=None) -def read_json_events(path: str, topic: str) -> Sequence[JsonEvent]: +_json_cache = {} +def _read_json_events_impl(path: str, topic: str) -> Sequence[JsonEvent]: """Read json events from the specified file.""" try: events = json.load(open(path), object_hook=JsonEvent) @@ -474,12 +474,16 @@ def read_json_events(path: str, topic: str) -> Sequence[JsonEvent]: if updates: for event in events: if event.metric_name in updates: - # print(f'Updated {event.metric_name} from\n"{event.metric_expr}"\n' - # f'to\n"{updates[event.metric_name]}"') event.metric_expr = updates[event.metric_name] return events +def read_json_events(path: str, topic: str) -> Sequence[JsonEvent]: + key = (path, topic) + if key not in _json_cache: + _json_cache[key] = _read_json_events_impl(path, topic) + return _json_cache[key] + def preprocess_arch_std_files(archpath: str) -> None: """Read in all architecture standard events.""" global _arch_std_events @@ -1381,6 +1385,10 @@ const char *describe_metricgroup(const char *group) } """) +def _parallel_read_json_events(task: Tuple[str, str]) -> Tuple[str, str, Sequence[JsonEvent]]: + path, topic = task + return path, topic, _read_json_events_impl(path, topic) + def main() -> None: global _args @@ -1459,9 +1467,29 @@ struct pmu_table_entry { raise IOError(f'Missing architecture directory \'{_args.arch}\'') archs.sort() + import concurrent.futures + tasks = [] + def collect_json(parents: Sequence[str], item: os.DirEntry) -> None: + if len(parents) == 0: + return + if item.is_file() and item.name.endswith('.json') and not item.name.endswith('metricgroups.json'): + tasks.append((item.path, get_topic(item.name))) + for arch in archs: arch_path = f'{_args.starting_dir}/{arch}' preprocess_arch_std_files(arch_path) + ftw(arch_path, [], collect_json) + + def _init_worker(std_events: dict) -> None: + global _arch_std_events + _arch_std_events = std_events + + with concurrent.futures.ProcessPoolExecutor(initializer=_init_worker, initargs=(_arch_std_events,)) as executor: + for path, topic, events in executor.map(_parallel_read_json_events, tasks): + _json_cache[(path, topic)] = events + + for arch in archs: + arch_path = f'{_args.starting_dir}/{arch}' ftw(arch_path, [], preprocess_one_file) _bcs.compute() -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v1 14/14] perf build: Prefix SCRIPTS with output directory to fix continuous rebuilds 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers ` (12 preceding siblings ...) 2026-05-12 5:35 ` [PATCH v1 13/14] perf pmu-events: Parallelize JSON and metric pre-computation in jevents.py Ian Rogers @ 2026-05-12 5:35 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers 2026-05-12 9:36 ` [PATCH v1 00/14] perf build: Reduce build time by one third James Clark 14 siblings, 1 reply; 36+ messages in thread From: Ian Rogers @ 2026-05-12 5:35 UTC (permalink / raw) To: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, James Clark, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users Cc: Ian Rogers In Makefile.perf, ALL_PROGRAMS includes SCRIPTS (perf-archive, perf-iostat). However, unlike PROGRAMS and DLFILTERS, SCRIPTS was not prefixed with $(OUTPUT). During out-of-tree builds (or when O= is specified), Make checked for the unprefixed target 'tools/perf/perf-archive'. Since the actual script was installed into $(OUTPUT)perf-archive, Make concluded the target was missing and continuously re-executed the script installation rule on every single incremental build. Prefix SCRIPTS with $(OUTPUT) and update the static pattern rule to ensure Kbuild correctly tracks generated script prerequisites during incremental builds. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 98b6f9fda8d1..e700cc1ed028 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -405,7 +405,7 @@ python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT # Use the detected configuration -include $(OUTPUT).config-detected -SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) +SCRIPTS = $(addprefix $(OUTPUT),$(patsubst %.sh,%,$(SCRIPT_SH))) PROGRAMS += $(OUTPUT)perf @@ -592,8 +592,8 @@ $(GTK_IN): FORCE prepare $(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS) $(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS) -$(SCRIPTS) : % : %.sh - $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@' +$(SCRIPTS) : $(OUTPUT)% : %.sh + $(QUIET_GEN)$(INSTALL) '$<' '$@' $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE $(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 00/18] perf build: Reduce build time by nearly half 2026-05-12 5:35 ` [PATCH v1 14/14] perf build: Prefix SCRIPTS with output directory to fix continuous rebuilds Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 01/18] bpftool build: Restrict feature tests during bootstrap compilation Ian Rogers ` (17 more replies) 0 siblings, 18 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song This patch series refactors Kbuild internals, BPF skeleton generation, Python AST pre-computation, and foundational tooling dependencies across the perf tool build system. By eliminating umbrella target synchronization barriers, decoupling static library prerequisites, parallelizing single-core script generators, and eradicating redundant feature checks, this series unlocks absolute theoretical peak multi-core concurrency during Kbuild startup. On a 28-core build workstation (make -j28 all from scratch), clean build latency improves by over 46%: Before: real 0m29.006s user 2m46.019s sys 0m30.610s After: real 0m15.655s user 2m43.051s sys 0m26.437s Saving 13.3 full seconds time per clean build. Furthermore, nothing to build incremental builds are improved by nearly 7x: Before: real 0m11.528s user 0m9.633s sys 0m6.965s After: real 0m1.665s user 0m1.501s sys 0m0.841s Summary of Patches: 1-4: Foundational Tooling & Fast-Path Feature Detection - Exempts bpftool bootstrap from non-essential feature tests (LLVM, libbfd, libcap), saving 1.1s of sub-make fork overhead during Kbuild startup. - Integrates libdebuginfod directly into test-all.c, allowing Make to skip individual feature check sub-make forks during AST parsing on fully configured workstations. - Fixes test-clang-bpf-co-re.bin feature check to correctly generate its target file on disk, allowing Kbuild to perfectly cache the detection result and avoid continuous sub-make re-evaluations. - Short-circuits CC_NO_CLANG compiler inspection probe in Makefile.include by exporting the cached result, eliminating 40+ redundant compiler forks across the sub-make hierarchy. 5-7: Flattening Umbrella Prepare Barriers - builtin-trace embedded inclusions and pmu-events generation are completely decoupled from the sequential "prepare" umbrella target, eliminating Make AST double-parsing overhead and unchoking parallel compilation barriers. 8-11: Decoupling & Pre-generating BPF Skeletons - BPF skeleton rules are extracted out of Makefile.perf into bpf_skel.mak. - Decouples bpftool bootstrap from top-level static libbpf dependencies, attaching bpf-skel-prepare directly to the umbrella prepare target. This allows Make to pre-compile bpftool and dump vmlinux.h in the background at build startup, removing the 7-second serialization bottleneck before BPF object compilation. 12-13: Foundational Linkage Optimization - Eliminates redundant libbpf sub-make feature checks during static builds. - Moves static libsymbol and libbpf library prerequisites out of the prepare step. 14-15: jevents.py Concurrency & Deduplication - Splits the massive 2.8 MB big_c_string literal out of pmu-events.c into a dedicated pmu-events-string.c compilation unit. This slices C compilation latency in half by compiling string and struct tables simultaneously across separate CPU cores while preserving zero dynamic ELF relocations. - Pre-populates jevents.py JSON ASTs and metric formulas in parallel across all available CPU cores using ProcessPoolExecutor (accelerating Python execution by 11x, from 3.3s down to ~290ms). 16: Out-of-Tree Incremental Rebuild Fix - Prefixes SCRIPTS (perf-archive, perf-iostat) with $(OUTPUT) to prevent Make from continuously re-executing script installation rules on already built out-of-tree builds. 17-18: AST Parsing Optimization & Shell Fork Eradication - Converts ZENS, ARMS, and INTELS in pmu-events/Build from recursive assignment (=) to simply expanded assignment (:=) and replaces model_name/vendor_name with pure GNU Make string functions. This guarantees Make executes directory probing shell forks exactly once during AST parsing and evaluates path macros purely in memory, completely eradicating over 7,800 redundant sub-processes during out-of-tree build evaluation. - Converts llvm-config shell queries in Makefile.config from recursive assignment (=) to simply expanded assignment (:=). This eliminates ~185 redundant sub-processes that were previously executed across object compilation dependency checks. Changes since v1: - Reorganized commit order so foundational build system and script infrastructure patches precede perf tool refactoring. - Added Tested-by tag from James Clark on v1 patches. - Eliminated redundant llvm-config shell forks and simply expanded PMU directory probing variables, wiping out over 7,800 redundant sub-processes during AST parsing. - Fixed test-clang-bpf-co-re.bin feature check caching and short-circuited CC_NO_CLANG compiler probes across sub-makes. Ian Rogers (18): bpftool build: Restrict feature tests during bootstrap compilation tools build: Integrate libdebuginfod into test-all fast path tools build: Fix test-clang-bpf-co-re.bin to generate target file tools scripts: Short-circuit CC_NO_CLANG compiler probe in Makefile.include perf trace beauty: Make beauty generated C code standalone .o files perf build: Decouple pmu-events from prepare umbrella target perf build: Remove empty archheaders target perf build: Move BPF skeleton generation out of Makefile.perf perf build: Encapsulate vmlinux.h and bpftool in bpf_skel.mak perf build: Move static libbpf dependency out of prepare step perf build: Pre-generate BPF skeleton tooling during umbrella prepare phase perf build: Move libsymbol dependency out of prepare step perf build: Remove redundant libbpf feature check for static builds perf pmu-events: Split big_c_string storage into standalone compilation unit perf pmu-events: Parallelize JSON and metric pre-computation in jevents.py perf build: Prefix SCRIPTS with output directory to fix continuous rebuilds perf pmu-events: Convert recursive shell assignments and macros to Make built-ins perf build: Convert llvm-config shell queries to simply expanded variables tools/bpf/bpftool/Makefile | 5 + tools/build/Makefile.feature | 6 +- tools/build/feature/Makefile | 4 +- tools/build/feature/test-all.c | 5 + tools/perf/Build | 2 + tools/perf/Makefile.config | 19 +- tools/perf/Makefile.perf | 427 +----------------- tools/perf/bench/Build | 6 + .../bpf_skel/bench_uprobe.bpf.c | 0 tools/perf/bench/uprobe.c | 2 +- tools/perf/bpf_skel.mak | 110 +++++ tools/perf/builtin-trace.c | 30 +- tools/perf/pmu-events/Build | 25 +- tools/perf/pmu-events/jevents.py | 56 ++- tools/perf/trace/beauty/Build | 280 ++++++++++++ tools/perf/trace/beauty/arch_errno_names.c | 2 + tools/perf/trace/beauty/arch_errno_names.sh | 2 +- tools/perf/trace/beauty/beauty.h | 60 +++ tools/perf/trace/beauty/eventfd.c | 6 +- tools/perf/trace/beauty/fsconfig.c | 5 + tools/perf/trace/beauty/futex_op.c | 6 +- tools/perf/trace/beauty/futex_val3.c | 6 +- tools/perf/trace/beauty/mmap.c | 24 +- tools/perf/trace/beauty/mode_t.c | 6 +- tools/perf/trace/beauty/msg_flags.c | 8 +- tools/perf/trace/beauty/open_flags.c | 1 + tools/perf/trace/beauty/perf_event_open.c | 22 +- tools/perf/trace/beauty/pid.c | 5 +- tools/perf/trace/beauty/sched_policy.c | 8 +- tools/perf/trace/beauty/seccomp.c | 12 +- tools/perf/trace/beauty/signum.c | 6 +- tools/perf/trace/beauty/socket_type.c | 6 +- .../perf/{util => trace/beauty}/syscalltbl.c | 0 .../perf/{util => trace/beauty}/syscalltbl.h | 0 tools/perf/trace/beauty/tracepoints/Build | 22 + tools/perf/trace/beauty/waitid_options.c | 8 +- tools/perf/util/Build | 17 +- tools/perf/util/bpf-trace-summary.c | 2 +- tools/perf/util/env.c | 4 +- tools/perf/util/env.h | 1 + tools/scripts/Makefile.include | 3 + 41 files changed, 716 insertions(+), 503 deletions(-) rename tools/perf/{util => bench}/bpf_skel/bench_uprobe.bpf.c (100%) create mode 100644 tools/perf/bpf_skel.mak create mode 100644 tools/perf/trace/beauty/fsconfig.c rename tools/perf/{util => trace/beauty}/syscalltbl.c (100%) rename tools/perf/{util => trace/beauty}/syscalltbl.h (100%) -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply [flat|nested] 36+ messages in thread
* [PATCH v2 01/18] bpftool build: Restrict feature tests during bootstrap compilation 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 02/18] tools build: Integrate libdebuginfod into test-all fast path Ian Rogers ` (16 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song When bpf_skel.mak executes 'make -C ../bpf/bpftool bootstrap', bpftool's Makefile unconditionally evaluated feature checks for llvm, libcap, libbfd, and disassembler libraries because the bootstrap target was not exempted. Since the bootstrap bpftool strictly compiles minimal AST parsing and C code generation logic without linking LLVM or disassembler libraries, these feature check sub-makes are completely redundant. Exempt the bootstrap target from non-essential feature tests to eliminate unneeded sub-make fork overhead during Kbuild startup. Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/bpf/bpftool/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 0febf60e1b64..8f50bc163bb2 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -106,6 +106,10 @@ ifneq ($(SKIP_CRYPTO),1) CRYPTO_LIBS := -lcrypto endif +ifeq ($(MAKECMDGOALS),bootstrap) +FEATURE_TESTS := libelf-zstd +FEATURE_DISPLAY := +else FEATURE_TESTS := clang-bpf-co-re FEATURE_TESTS += llvm FEATURE_TESTS += libcap @@ -122,6 +126,7 @@ FEATURE_DISPLAY += libcap FEATURE_DISPLAY += libbfd FEATURE_DISPLAY += libbfd-liberty FEATURE_DISPLAY += libbfd-liberty-z +endif check_feat := 1 NON_CHECK_FEAT_TARGETS := clean uninstall doc doc-clean doc-install doc-uninstall -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 02/18] tools build: Integrate libdebuginfod into test-all fast path 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers 2026-05-12 17:46 ` [PATCH v2 01/18] bpftool build: Restrict feature tests during bootstrap compilation Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 03/18] tools build: Fix test-clang-bpf-co-re.bin to generate target file Ian Rogers ` (15 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song Bundling libdebuginfod into test-all.c allows Make to avoid an individual feature check sub-make fork during AST parsing. Short-circuit feature_check in Makefile.feature to instantly skip sub-make evaluations when a feature was already pre-detected by test-all. Trade-offs: On some Linux distributions (e.g., Debian/Ubuntu), libdebuginfod-dev is packaged separately from libelf-dev and libdw-dev. If a user installs libdw-dev but omits libdebuginfod-dev, adding -ldebuginfod to BUILD_ALL causes test-all to fail, falling back to individual feature tests. However, on fully configured developer workstations, this successfully reclaims sequential startup latency. Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/build/Makefile.feature | 6 ++++-- tools/build/feature/Makefile | 2 +- tools/build/feature/test-all.c | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature index 2f192d3bf61b..d8febe5d5800 100644 --- a/tools/build/Makefile.feature +++ b/tools/build/Makefile.feature @@ -8,7 +8,9 @@ endif feature_check = $(eval $(feature_check_code)) define feature_check_code - feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC="$(CC)" CXX="$(CXX)" CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) + ifeq ($(feature-$(1)),) + feature-$(1) := $(shell $(MAKE) OUTPUT=$(OUTPUT_FEATURES) CC="$(CC)" CXX="$(CXX)" CFLAGS="$(EXTRA_CFLAGS) $(FEATURE_CHECK_CFLAGS-$(1))" CXXFLAGS="$(EXTRA_CXXFLAGS) $(FEATURE_CHECK_CXXFLAGS-$(1))" LDFLAGS="$(LDFLAGS) $(FEATURE_CHECK_LDFLAGS-$(1))" -C $(feature_dir) $(OUTPUT_FEATURES)test-$1.bin >/dev/null 2>/dev/null && echo 1 || echo 0) + endif endef feature_set = $(eval $(feature_set_code)) @@ -100,6 +102,7 @@ FEATURE_TESTS_BASIC := \ disassembler-four-args \ disassembler-init-styled \ file-handle \ + libdebuginfod \ libopenssl # FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list @@ -125,7 +128,6 @@ FEATURE_TESTS_EXTRA := \ clang \ libbpf \ libpfm4 \ - libdebuginfod \ clang-bpf-co-re \ bpftool-skeletons diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index 704c687ed3ad..dc828523b50a 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -115,7 +115,7 @@ __BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $( BUILD_BFD = $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang \ $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -ldl -lz -llzma -lzstd \ - $(shell $(PKG_CONFIG) --libs --cflags openssl 2>/dev/null) + $(shell $(PKG_CONFIG) --libs --cflags openssl 2>/dev/null) -ldebuginfod __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS) BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1 diff --git a/tools/build/feature/test-all.c b/tools/build/feature/test-all.c index 1488bf6e6078..b6984236859f 100644 --- a/tools/build/feature/test-all.c +++ b/tools/build/feature/test-all.c @@ -146,6 +146,10 @@ # include "test-libopenssl.c" #undef main +#define main main_test_libdebuginfod +# include "test-libdebuginfod.c" +#undef main + int main(int argc, char *argv[]) { main_test_libpython(); @@ -178,6 +182,7 @@ int main(int argc, char *argv[]) main_test_libzstd(); main_test_libtraceevent(); main_test_libopenssl(); + main_test_libdebuginfod(); return 0; } -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 03/18] tools build: Fix test-clang-bpf-co-re.bin to generate target file 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers 2026-05-12 17:46 ` [PATCH v2 01/18] bpftool build: Restrict feature tests during bootstrap compilation Ian Rogers 2026-05-12 17:46 ` [PATCH v2 02/18] tools build: Integrate libdebuginfod into test-all fast path Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 04/18] tools scripts: Short-circuit CC_NO_CLANG compiler probe in Makefile.include Ian Rogers ` (14 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song In tools/build/feature/Makefile, the test-clang-bpf-co-re.bin feature check compiled test-clang-bpf-co-re.c assembly on stdout and piped it to grep, but never redirected the matched output to create the target binary () on disk. Because the target file was never created, Kbuild could never cache the result of the check. Consequently, Make treated the prerequisite as missing and continuously re-executed the Clang BPF backend compilation check on every single sub-make evaluation during build startup. Redirect grep output to to guarantee the file is created on disk upon success, allowing Kbuild to perfectly cache the detection result and avoid redundant sub-make forks. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/build/feature/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile index dc828523b50a..f43f85738b5d 100644 --- a/tools/build/feature/Makefile +++ b/tools/build/feature/Makefile @@ -385,7 +385,7 @@ $(OUTPUT)test-libzstd.bin: $(OUTPUT)test-clang-bpf-co-re.bin: $(CLANG) -S -g --target=bpf -o - $(patsubst %.bin,%.c,$(@F)) | \ - grep BTF_KIND_VAR + grep BTF_KIND_VAR > $@ $(OUTPUT)test-file-handle.bin: $(BUILD) -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 04/18] tools scripts: Short-circuit CC_NO_CLANG compiler probe in Makefile.include 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (2 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 03/18] tools build: Fix test-clang-bpf-co-re.bin to generate target file Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 05/18] perf trace beauty: Make beauty generated C code standalone .o files Ian Rogers ` (13 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song In Makefile.include, CC_NO_CLANG unconditionally executed a GCC/Clang compiler inspection fork (gcc -dM -E ...) during Makefile parse time. Because Makefile.include is included across more than 40 sub-makes and component directories throughout the Kbuild tree, Make continuously re-executed this compiler probe dozens of times during incremental builds. Wrap CC_NO_CLANG with a conditional check and export the variable to sub-makes. This guarantees Kbuild evaluates the compiler backend exactly once during top-level Make invocation, eliminating 40+ redundant shell forks across the build tree. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/scripts/Makefile.include | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index 41971a68972d..3c7803122ae2 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -74,7 +74,10 @@ $(call allow-override,CXX,$(CROSS_COMPILE)g++) $(call allow-override,STRIP,$(CROSS_COMPILE)strip) endif +ifeq ($(CC_NO_CLANG),) CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?) +endif +export CC_NO_CLANG ifneq ($(LLVM),) HOSTAR ?= $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX) -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 05/18] perf trace beauty: Make beauty generated C code standalone .o files 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (3 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 04/18] tools scripts: Short-circuit CC_NO_CLANG compiler probe in Makefile.include Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 06/18] perf build: Decouple pmu-events from prepare umbrella target Ian Rogers ` (12 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song Previously, builtin-trace.c directly included 15 embedded C files (e.g. trace/beauty/mmap.c and fsconfig_arrays.c), which in turn depend on dozens of generated beauty script arrays. To satisfy these embedded inclusions, the global Makefile.perf would define all the generator variables/rules and include them in the massive sequential prepare umbrella target, choking parallel build startup. Furthermore, tools/perf/util/syscalltbl.c included its own generated mapper, and util/env.c conditionally included arch_errno_names.c inline, splitting consumers across directories and preventing clean Make encapsulation. Refactor the framework to achieve better encapsulation: 1. Move util/syscalltbl.[ch] into trace/beauty/ to co-locate with all generated code consumers. 2. Create fsconfig.c and flatten embedded beauty .c files to compile as independent standalone objects via trace/beauty/Build, exporting their formatting functions via beauty.h and env.h. Switch arch_errno_names.o and syscalltbl.o assignments directly to perf-util-y and add a top-level recursive kbuild hook (perf-util-$(CONFIG_TRACE) += trace/beauty/) to compile them into libperf-util.a, resolving remote linkage for standalone python extensions. 3. Bridge private opaque references (struct trace) securely via accessors trace__show_zeros() and trace__host(), avoiding header entanglements. 4. Consolidate all generator variables, script paths, and array generation rules entirely out of Makefile.perf and place them directly inside the exact local Build files where their output objects are compiled (trace/beauty/Build and trace/beauty/tracepoints/Build), binding prerequisites locally. Use $(call rule_mkdir) directly inside generator recipes to guarantee dynamic directory creation before script redirection, and append $(call echo-cmd,gen) across all rules to print clean, standardized GEN ... file.c output during compilation. 5. Clean up clean target to recursively remove the generated directory instead of relying on dozens of individual variables. This unchokes the "prepare" target parallel barrier, allows make to evaluate generation scripts purely locally where consumed, and flattens the tracepoint formatting architecture. Testing a parallel build (make -j28 all from scratch) shows improvements: Before: real 0m28.689s user 2m38.490s sys 0m30.148s After: real 0m27.642s user 2m32.356s sys 0m26.683s So reclaiming ~9.6 seconds of raw CPU time and over 1 full second off overall real-world build latency, by overlapping sub-make startup and avoiding top-level double-parsing overhead. Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Build | 2 + tools/perf/Makefile.perf | 282 +----------------- tools/perf/builtin-trace.c | 30 +- tools/perf/trace/beauty/Build | 280 +++++++++++++++++ tools/perf/trace/beauty/arch_errno_names.c | 2 + tools/perf/trace/beauty/arch_errno_names.sh | 2 +- tools/perf/trace/beauty/beauty.h | 60 ++++ tools/perf/trace/beauty/eventfd.c | 6 +- tools/perf/trace/beauty/fsconfig.c | 5 + tools/perf/trace/beauty/futex_op.c | 6 +- tools/perf/trace/beauty/futex_val3.c | 6 +- tools/perf/trace/beauty/mmap.c | 24 +- tools/perf/trace/beauty/mode_t.c | 6 +- tools/perf/trace/beauty/msg_flags.c | 8 +- tools/perf/trace/beauty/open_flags.c | 1 + tools/perf/trace/beauty/perf_event_open.c | 22 +- tools/perf/trace/beauty/pid.c | 5 +- tools/perf/trace/beauty/sched_policy.c | 8 +- tools/perf/trace/beauty/seccomp.c | 12 +- tools/perf/trace/beauty/signum.c | 6 +- tools/perf/trace/beauty/socket_type.c | 6 +- .../perf/{util => trace/beauty}/syscalltbl.c | 0 .../perf/{util => trace/beauty}/syscalltbl.h | 0 tools/perf/trace/beauty/tracepoints/Build | 22 ++ tools/perf/trace/beauty/waitid_options.c | 8 +- tools/perf/util/Build | 4 +- tools/perf/util/bpf-trace-summary.c | 2 +- tools/perf/util/env.c | 4 +- tools/perf/util/env.h | 1 + 29 files changed, 468 insertions(+), 352 deletions(-) create mode 100644 tools/perf/trace/beauty/fsconfig.c rename tools/perf/{util => trace/beauty}/syscalltbl.c (100%) rename tools/perf/{util => trace/beauty}/syscalltbl.h (100%) diff --git a/tools/perf/Build b/tools/perf/Build index b03cc59dabf8..e18c80a5c1bc 100644 --- a/tools/perf/Build +++ b/tools/perf/Build @@ -34,6 +34,8 @@ ifeq ($(CONFIG_LIBTRACEEVENT),y) perf-$(CONFIG_TRACE) += trace/beauty/ endif +perf-util-y += trace/beauty/ + perf-$(CONFIG_LIBELF) += builtin-probe.o perf-bench-y += bench/ diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 0aba14f22a06..c81797ceec42 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -509,225 +509,6 @@ arm64-sysreg-defs-clean: $(Q)$(MAKE) -C $(arm64_gen_sysreg_dir) O=$(arm64_gen_sysreg_outdir) \ prefix= subdir= clean > /dev/null -beauty_linux_dir := $(srctree)/tools/perf/trace/beauty/include/linux/ -beauty_uapi_linux_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/linux/ -beauty_uapi_sound_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/sound/ -beauty_arch_asm_dir := $(srctree)/tools/perf/trace/beauty/arch/x86/include/asm/ -beauty_x86_arch_asm_uapi_dir := $(srctree)/tools/perf/trace/beauty/arch/x86/include/uapi/asm/ - -linux_uapi_dir := $(srctree)/tools/include/uapi/linux -asm_generic_uapi_dir := $(srctree)/tools/include/uapi/asm-generic -arch_asm_uapi_dir := $(srctree)/tools/arch/$(SRCARCH)/include/uapi/asm/ -x86_arch_asm_dir := $(srctree)/tools/arch/x86/include/asm/ - -beauty_outdir := $(OUTPUT)trace/beauty/generated -beauty_ioctl_outdir := $(beauty_outdir)/ioctl - -# Create output directory if not already present -$(shell [ -d '$(beauty_ioctl_outdir)' ] || mkdir -p '$(beauty_ioctl_outdir)') - -syscall_array := $(beauty_outdir)/syscalltbl.c -syscall_tbl := $(srctree)/tools/perf/trace/beauty/syscalltbl.sh -syscall_tbl_data := $(srctree)/tools/scripts/syscall.tbl \ - $(wildcard $(srctree)/tools/perf/arch/*/entry/syscalls/syscall*.tbl) - -$(syscall_array): $(syscall_tbl) $(syscall_tbl_data) - $(Q)$(SHELL) '$(syscall_tbl)' $(srctree)/tools $@ - -fs_at_flags_array := $(beauty_outdir)/fs_at_flags_array.c -fs_at_flags_tbl := $(srctree)/tools/perf/trace/beauty/fs_at_flags.sh - -$(fs_at_flags_array): $(beauty_uapi_linux_dir)/fcntl.h $(fs_at_flags_tbl) - $(Q)$(SHELL) '$(fs_at_flags_tbl)' $(beauty_uapi_linux_dir) > $@ - -clone_flags_array := $(beauty_outdir)/clone_flags_array.c -clone_flags_tbl := $(srctree)/tools/perf/trace/beauty/clone.sh - -$(clone_flags_array): $(beauty_uapi_linux_dir)/sched.h $(clone_flags_tbl) - $(Q)$(SHELL) '$(clone_flags_tbl)' $(beauty_uapi_linux_dir) > $@ - -drm_ioctl_array := $(beauty_ioctl_outdir)/drm_ioctl_array.c -drm_hdr_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/drm -drm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/drm_ioctl.sh - -$(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl) - $(Q)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@ - -fadvise_advice_array := $(beauty_outdir)/fadvise_advice_array.c -fadvise_advice_tbl := $(srctree)/tools/perf/trace/beauty/fadvise.sh - -$(fadvise_advice_array): $(beauty_uapi_linux_dir)/fadvise.h $(fadvise_advice_tbl) - $(Q)$(SHELL) '$(fadvise_advice_tbl)' $(beauty_uapi_linux_dir) > $@ - -fsmount_arrays := $(beauty_outdir)/fsmount_arrays.c -fsmount_tbls := $(srctree)/tools/perf/trace/beauty/fsmount.sh - -$(fsmount_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsmount_tbls) - $(Q)$(SHELL) '$(fsmount_tbls)' $(beauty_uapi_linux_dir) > $@ - -fspick_arrays := $(beauty_outdir)/fspick_arrays.c -fspick_tbls := $(srctree)/tools/perf/trace/beauty/fspick.sh - -$(fspick_arrays): $(beauty_uapi_linux_dir)/mount.h $(fspick_tbls) - $(Q)$(SHELL) '$(fspick_tbls)' $(beauty_uapi_linux_dir) > $@ - -fsconfig_arrays := $(beauty_outdir)/fsconfig_arrays.c -fsconfig_tbls := $(srctree)/tools/perf/trace/beauty/fsconfig.sh - -$(fsconfig_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsconfig_tbls) - $(Q)$(SHELL) '$(fsconfig_tbls)' $(beauty_uapi_linux_dir) > $@ - -pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c -asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/ -pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh - -$(pkey_alloc_access_rights_array): $(asm_generic_hdr_dir)/mman-common.h $(pkey_alloc_access_rights_tbl) - $(Q)$(SHELL) '$(pkey_alloc_access_rights_tbl)' $(asm_generic_hdr_dir) > $@ - -sndrv_ctl_ioctl_array := $(beauty_ioctl_outdir)/sndrv_ctl_ioctl_array.c -sndrv_ctl_hdr_dir := $(srctree)/tools/include/uapi/sound -sndrv_ctl_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh - -$(sndrv_ctl_ioctl_array): $(beauty_uapi_sound_dir)/asound.h $(sndrv_ctl_ioctl_tbl) - $(Q)$(SHELL) '$(sndrv_ctl_ioctl_tbl)' $(beauty_uapi_sound_dir) > $@ - -sndrv_pcm_ioctl_array := $(beauty_ioctl_outdir)/sndrv_pcm_ioctl_array.c -sndrv_pcm_hdr_dir := $(srctree)/tools/include/uapi/sound -sndrv_pcm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh - -$(sndrv_pcm_ioctl_array): $(beauty_uapi_sound_dir)/asound.h $(sndrv_pcm_ioctl_tbl) - $(Q)$(SHELL) '$(sndrv_pcm_ioctl_tbl)' $(beauty_uapi_sound_dir) > $@ - -kcmp_type_array := $(beauty_outdir)/kcmp_type_array.c -kcmp_hdr_dir := $(srctree)/tools/include/uapi/linux/ -kcmp_type_tbl := $(srctree)/tools/perf/trace/beauty/kcmp_type.sh - -$(kcmp_type_array): $(kcmp_hdr_dir)/kcmp.h $(kcmp_type_tbl) - $(Q)$(SHELL) '$(kcmp_type_tbl)' $(kcmp_hdr_dir) > $@ - -kvm_ioctl_array := $(beauty_ioctl_outdir)/kvm_ioctl_array.c -kvm_hdr_dir := $(srctree)/tools/include/uapi/linux -kvm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/kvm_ioctl.sh - -$(kvm_ioctl_array): $(kvm_hdr_dir)/kvm.h $(kvm_ioctl_tbl) - $(Q)$(SHELL) '$(kvm_ioctl_tbl)' $(kvm_hdr_dir) > $@ - -socket_arrays := $(beauty_outdir)/socket.c -socket_tbl := $(srctree)/tools/perf/trace/beauty/socket.sh - -$(socket_arrays): $(linux_uapi_dir)/in.h $(beauty_linux_dir)/socket.h $(socket_tbl) - $(Q)$(SHELL) '$(socket_tbl)' $(linux_uapi_dir) $(beauty_linux_dir) > $@ - -sockaddr_arrays := $(beauty_outdir)/sockaddr.c -sockaddr_tbl := $(srctree)/tools/perf/trace/beauty/sockaddr.sh - -$(sockaddr_arrays): $(beauty_linux_dir)/socket.h $(sockaddr_tbl) - $(Q)$(SHELL) '$(sockaddr_tbl)' $(beauty_linux_dir) > $@ - -vhost_virtio_ioctl_array := $(beauty_ioctl_outdir)/vhost_virtio_ioctl_array.c -vhost_virtio_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/vhost_virtio_ioctl.sh - -$(vhost_virtio_ioctl_array): $(beauty_uapi_linux_dir)/vhost.h $(vhost_virtio_ioctl_tbl) - $(Q)$(SHELL) '$(vhost_virtio_ioctl_tbl)' $(beauty_uapi_linux_dir) > $@ - -perf_ioctl_array := $(beauty_ioctl_outdir)/perf_ioctl_array.c -perf_hdr_dir := $(srctree)/tools/include/uapi/linux -perf_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/perf_ioctl.sh - -$(perf_ioctl_array): $(perf_hdr_dir)/perf_event.h $(perf_ioctl_tbl) - $(Q)$(SHELL) '$(perf_ioctl_tbl)' $(perf_hdr_dir) > $@ - -madvise_behavior_array := $(beauty_outdir)/madvise_behavior_array.c -madvise_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/ -madvise_behavior_tbl := $(srctree)/tools/perf/trace/beauty/madvise_behavior.sh - -$(madvise_behavior_array): $(madvise_hdr_dir)/mman-common.h $(madvise_behavior_tbl) - $(Q)$(SHELL) '$(madvise_behavior_tbl)' $(madvise_hdr_dir) > $@ - -mmap_flags_array := $(beauty_outdir)/mmap_flags_array.c -mmap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mmap_flags.sh - -$(mmap_flags_array): $(linux_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl) - $(Q)$(SHELL) '$(mmap_flags_tbl)' $(linux_uapi_dir) $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ - -mremap_flags_array := $(beauty_outdir)/mremap_flags_array.c -mremap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mremap_flags.sh - -$(mremap_flags_array): $(linux_uapi_dir)/mman.h $(mremap_flags_tbl) - $(Q)$(SHELL) '$(mremap_flags_tbl)' $(linux_uapi_dir) > $@ - -mount_flags_array := $(beauty_outdir)/mount_flags_array.c -mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.sh - -$(mount_flags_array): $(beauty_uapi_linux_dir)/mount.h $(mount_flags_tbl) - $(Q)$(SHELL) '$(mount_flags_tbl)' $(beauty_uapi_linux_dir) > $@ - -move_mount_flags_array := $(beauty_outdir)/move_mount_flags_array.c -move_mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/move_mount_flags.sh - -$(move_mount_flags_array): $(beauty_uapi_linux_dir)/mount.h $(move_mount_flags_tbl) - $(Q)$(SHELL) '$(move_mount_flags_tbl)' $(beauty_uapi_linux_dir) > $@ - -mmap_prot_array := $(beauty_outdir)/mmap_prot_array.c -mmap_prot_tbl := $(srctree)/tools/perf/trace/beauty/mmap_prot.sh - -$(mmap_prot_array): $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_prot_tbl) - $(Q)$(SHELL) '$(mmap_prot_tbl)' $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ - -prctl_option_array := $(beauty_outdir)/prctl_option_array.c -prctl_option_tbl := $(srctree)/tools/perf/trace/beauty/prctl_option.sh - -$(prctl_option_array): $(beauty_uapi_linux_dir)/prctl.h $(prctl_option_tbl) - $(Q)$(SHELL) '$(prctl_option_tbl)' $(beauty_uapi_linux_dir) > $@ - -usbdevfs_ioctl_array := $(beauty_ioctl_outdir)/usbdevfs_ioctl_array.c -usbdevfs_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/usbdevfs_ioctl.sh - -$(usbdevfs_ioctl_array): $(beauty_uapi_linux_dir)/usbdevice_fs.h $(usbdevfs_ioctl_tbl) - $(Q)$(SHELL) '$(usbdevfs_ioctl_tbl)' $(beauty_uapi_linux_dir) > $@ - -x86_arch_prctl_code_array := $(beauty_outdir)/x86_arch_prctl_code_array.c -x86_arch_prctl_code_tbl := $(srctree)/tools/perf/trace/beauty/x86_arch_prctl.sh - -$(x86_arch_prctl_code_array): $(beauty_x86_arch_asm_uapi_dir)/prctl.h $(x86_arch_prctl_code_tbl) - $(Q)$(SHELL) '$(x86_arch_prctl_code_tbl)' $(beauty_x86_arch_asm_uapi_dir) > $@ - -x86_arch_irq_vectors_array := $(beauty_outdir)/x86_arch_irq_vectors_array.c -x86_arch_irq_vectors_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh - -$(x86_arch_irq_vectors_array): $(beauty_arch_asm_dir)/irq_vectors.h $(x86_arch_irq_vectors_tbl) - $(Q)$(SHELL) '$(x86_arch_irq_vectors_tbl)' $(beauty_arch_asm_dir) > $@ - -x86_arch_MSRs_array := $(beauty_outdir)/x86_arch_MSRs_array.c -x86_arch_MSRs_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_msr.sh - -$(x86_arch_MSRs_array): $(x86_arch_asm_dir)/msr-index.h $(x86_arch_MSRs_tbl) - $(Q)$(SHELL) '$(x86_arch_MSRs_tbl)' $(x86_arch_asm_dir) > $@ - -rename_flags_array := $(beauty_outdir)/rename_flags_array.c -rename_flags_tbl := $(srctree)/tools/perf/trace/beauty/rename_flags.sh - -$(rename_flags_array): $(beauty_uapi_linux_dir)/fs.h $(rename_flags_tbl) - $(Q)$(SHELL) '$(rename_flags_tbl)' $(beauty_uapi_linux_dir) > $@ - -arch_errno_name_array := $(beauty_outdir)/arch_errno_name_array.c -arch_errno_hdr_dir := $(srctree)/tools -arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh - -$(arch_errno_name_array): $(arch_errno_tbl) - $(Q)$(SHELL) '$(arch_errno_tbl)' '$(patsubst -%,,$(CC))' $(arch_errno_hdr_dir) > $@ - -statx_mask_array := $(beauty_outdir)/statx_mask_array.c -statx_mask_tbl := $(srctree)/tools/perf/trace/beauty/statx_mask.sh - -$(statx_mask_array): $(beauty_uapi_linux_dir)/stat.h $(statx_mask_tbl) - $(Q)$(SHELL) '$(statx_mask_tbl)' $(beauty_uapi_linux_dir) > $@ - -sync_file_range_arrays := $(beauty_outdir)/sync_file_range_arrays.c -sync_file_range_tbls := $(srctree)/tools/perf/trace/beauty/sync_file_range.sh - -$(sync_file_range_arrays): $(beauty_uapi_linux_dir)/fs.h $(sync_file_range_tbls) - $(Q)$(SHELL) '$(sync_file_range_tbls)' $(beauty_uapi_linux_dir) > $@ TESTS_CORESIGHT_DIR := $(srctree)/tools/perf/tests/shell/coresight @@ -848,38 +629,6 @@ build-dir = $(or $(__build-dir),.) prepare: $(OUTPUT)PERF-VERSION-FILE archheaders \ arm64-sysreg-defs \ - $(syscall_array) \ - $(fs_at_flags_array) \ - $(clone_flags_array) \ - $(drm_ioctl_array) \ - $(fadvise_advice_array) \ - $(fsconfig_arrays) \ - $(fsmount_arrays) \ - $(fspick_arrays) \ - $(pkey_alloc_access_rights_array) \ - $(sndrv_pcm_ioctl_array) \ - $(sndrv_ctl_ioctl_array) \ - $(kcmp_type_array) \ - $(kvm_ioctl_array) \ - $(socket_arrays) \ - $(sockaddr_arrays) \ - $(vhost_virtio_ioctl_array) \ - $(madvise_behavior_array) \ - $(mmap_flags_array) \ - $(mmap_prot_array) \ - $(mremap_flags_array) \ - $(mount_flags_array) \ - $(move_mount_flags_array) \ - $(perf_ioctl_array) \ - $(prctl_option_array) \ - $(usbdevfs_ioctl_array) \ - $(x86_arch_irq_vectors_array) \ - $(x86_arch_MSRs_array) \ - $(x86_arch_prctl_code_array) \ - $(rename_flags_array) \ - $(arch_errno_name_array) \ - $(statx_mask_array) \ - $(sync_file_range_arrays) \ $(LIBAPI) \ $(LIBPERF) \ $(LIBSUBCMD) \ @@ -1299,35 +1048,8 @@ clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $( TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE \ $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \ $(OUTPUT)util/intel-pt-decoder/inat-tables.c \ - $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \ - $(OUTPUT)$(fadvise_advice_array) \ - $(OUTPUT)$(fsconfig_arrays) \ - $(OUTPUT)$(fsmount_arrays) \ - $(OUTPUT)$(fspick_arrays) \ - $(OUTPUT)$(madvise_behavior_array) \ - $(OUTPUT)$(mmap_flags_array) \ - $(OUTPUT)$(mmap_prot_array) \ - $(OUTPUT)$(mremap_flags_array) \ - $(OUTPUT)$(mount_flags_array) \ - $(OUTPUT)$(move_mount_flags_array) \ - $(OUTPUT)$(drm_ioctl_array) \ - $(OUTPUT)$(pkey_alloc_access_rights_array) \ - $(OUTPUT)$(sndrv_ctl_ioctl_array) \ - $(OUTPUT)$(sndrv_pcm_ioctl_array) \ - $(OUTPUT)$(kvm_ioctl_array) \ - $(OUTPUT)$(kcmp_type_array) \ - $(OUTPUT)$(socket_arrays) \ - $(OUTPUT)$(sockaddr_arrays) \ - $(OUTPUT)$(vhost_virtio_ioctl_array) \ - $(OUTPUT)$(perf_ioctl_array) \ - $(OUTPUT)$(prctl_option_array) \ - $(OUTPUT)$(usbdevfs_ioctl_array) \ - $(OUTPUT)$(x86_arch_irq_vectors_array) \ - $(OUTPUT)$(x86_arch_MSRs_array) \ - $(OUTPUT)$(x86_arch_prctl_code_array) \ - $(OUTPUT)$(rename_flags_array) \ - $(OUTPUT)$(arch_errno_name_array) \ - $(OUTPUT)$(sync_file_range_arrays) + $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c + $(Q)$(RM) -r $(OUTPUT)trace/beauty/generated $(call QUIET_CLEAN, Documentation) \ $(MAKE) -C $(DOC_DIR) O=$(OUTPUT) clean >/dev/null diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index e58c49d047a2..e6fe8e13f4e7 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -60,12 +60,13 @@ #include "callchain.h" #include "print_binary.h" #include "string2.h" -#include "syscalltbl.h" +#include "trace/beauty/syscalltbl.h" #include "../perf.h" #include "trace_augment.h" #include "dwarf-regs.h" #include <errno.h> +#include <sys/stat.h> #include <inttypes.h> #include <poll.h> #include <signal.h> @@ -234,6 +235,16 @@ struct trace { const char *uid_str; }; +bool trace__show_zeros(const struct trace *trace) +{ + return trace->show_zeros; +} + +struct machine *trace__host(const struct trace *trace) +{ + return trace->host; +} + static void trace__load_vmlinux_btf(struct trace *trace __maybe_unused) { #ifdef HAVE_LIBBPF_SUPPORT @@ -776,9 +787,7 @@ static const char *fsmount_flags[] = { }; static DEFINE_STRARRAY(fsmount_flags, "FSMOUNT_"); -#include "trace/beauty/generated/fsconfig_arrays.c" -static DEFINE_STRARRAY(fsconfig_cmds, "FSCONFIG_"); static const char *epoll_ctl_ops[] = { "ADD", "DEL", "MOD", }; static DEFINE_STRARRAY_OFFSET(epoll_ctl_ops, "EPOLL_CTL_", 1); @@ -1128,20 +1137,7 @@ static bool syscall_arg__strtoul_btf_type(char *bf __maybe_unused, size_t size _ .parm = &strarray__##array, \ .show_zero = true, } -#include "trace/beauty/eventfd.c" -#include "trace/beauty/futex_op.c" -#include "trace/beauty/futex_val3.c" -#include "trace/beauty/mmap.c" -#include "trace/beauty/mode_t.c" -#include "trace/beauty/msg_flags.c" -#include "trace/beauty/open_flags.c" -#include "trace/beauty/perf_event_open.c" -#include "trace/beauty/pid.c" -#include "trace/beauty/sched_policy.c" -#include "trace/beauty/seccomp.c" -#include "trace/beauty/signum.c" -#include "trace/beauty/socket_type.c" -#include "trace/beauty/waitid_options.c" + static const struct syscall_fmt syscall_fmts[] = { { .name = "access", diff --git a/tools/perf/trace/beauty/Build b/tools/perf/trace/beauty/Build index 561590ee8cda..83c1919ecebd 100644 --- a/tools/perf/trace/beauty/Build +++ b/tools/perf/trace/beauty/Build @@ -19,6 +19,23 @@ perf-y += socket.o perf-y += statx.o perf-y += sync_file_range.o perf-y += timespec.o +perf-util-y += syscalltbl.o +perf-y += fsconfig.o +perf-y += eventfd.o +perf-y += futex_op.o +perf-y += futex_val3.o +perf-y += mmap.o +perf-y += mode_t.o +perf-y += msg_flags.o +perf-y += open_flags.o +perf-y += perf_event_open.o +perf-y += pid.o +perf-y += sched_policy.o +perf-y += seccomp.o +perf-y += signum.o +perf-y += socket_type.o +perf-y += waitid_options.o +perf-util-y += arch_errno_names.o perf-y += tracepoints/ ifdef SHELLCHECK @@ -34,3 +51,266 @@ $(OUTPUT)%.shellcheck_log: % $(Q)$(call echo-cmd,test)$(SHELLCHECK) "$<" > $@ || (cat $@ && rm $@ && false) perf-y += $(SHELL_TEST_LOGS) + +# --- Encapsulated Beauty Generation Rules --- +beauty_linux_dir := $(srctree)/tools/perf/trace/beauty/include/linux/ +beauty_uapi_linux_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/linux/ +beauty_uapi_sound_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/sound/ +beauty_arch_asm_dir := $(srctree)/tools/perf/trace/beauty/arch/x86/include/asm/ +beauty_x86_arch_asm_uapi_dir := $(srctree)/tools/perf/trace/beauty/arch/x86/include/uapi/asm/ + +linux_uapi_dir := $(srctree)/tools/include/uapi/linux +asm_generic_uapi_dir := $(srctree)/tools/include/uapi/asm-generic +arch_asm_uapi_dir := $(srctree)/tools/arch/$(SRCARCH)/include/uapi/asm/ +x86_arch_asm_dir := $(srctree)/tools/arch/x86/include/asm/ + +beauty_outdir := $(OUTPUT)trace/beauty/generated +beauty_ioctl_outdir := $(beauty_outdir)/ioctl + +# Output directories are dynamically created by $(call rule_mkdir) in recipes + +syscall_array := $(beauty_outdir)/syscalltbl.c +syscall_tbl := $(srctree)/tools/perf/trace/beauty/syscalltbl.sh +syscall_tbl_data := $(srctree)/tools/scripts/syscall.tbl \ + $(wildcard $(srctree)/tools/perf/arch/*/entry/syscalls/syscall*.tbl) + +$(syscall_array): $(syscall_tbl) $(syscall_tbl_data) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(syscall_tbl)' $(srctree)/tools $@ + +fs_at_flags_array := $(beauty_outdir)/fs_at_flags_array.c +fs_at_flags_tbl := $(srctree)/tools/perf/trace/beauty/fs_at_flags.sh + +$(fs_at_flags_array): $(beauty_uapi_linux_dir)/fcntl.h $(fs_at_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(fs_at_flags_tbl)' $(beauty_uapi_linux_dir) > $@ + +clone_flags_array := $(beauty_outdir)/clone_flags_array.c +clone_flags_tbl := $(srctree)/tools/perf/trace/beauty/clone.sh + +$(clone_flags_array): $(beauty_uapi_linux_dir)/sched.h $(clone_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(clone_flags_tbl)' $(beauty_uapi_linux_dir) > $@ + +drm_ioctl_array := $(beauty_ioctl_outdir)/drm_ioctl_array.c +drm_hdr_dir := $(srctree)/tools/perf/trace/beauty/include/uapi/drm +drm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/drm_ioctl.sh + +$(drm_ioctl_array): $(drm_hdr_dir)/drm.h $(drm_hdr_dir)/i915_drm.h $(drm_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(drm_ioctl_tbl)' $(drm_hdr_dir) > $@ + +fadvise_advice_array := $(beauty_outdir)/fadvise_advice_array.c +fadvise_advice_tbl := $(srctree)/tools/perf/trace/beauty/fadvise.sh + +$(fadvise_advice_array): $(beauty_uapi_linux_dir)/fadvise.h $(fadvise_advice_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(fadvise_advice_tbl)' $(beauty_uapi_linux_dir) > $@ + +fsmount_arrays := $(beauty_outdir)/fsmount_arrays.c +fsmount_tbls := $(srctree)/tools/perf/trace/beauty/fsmount.sh + +$(fsmount_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsmount_tbls) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(fsmount_tbls)' $(beauty_uapi_linux_dir) > $@ + +fspick_arrays := $(beauty_outdir)/fspick_arrays.c +fspick_tbls := $(srctree)/tools/perf/trace/beauty/fspick.sh + +$(fspick_arrays): $(beauty_uapi_linux_dir)/mount.h $(fspick_tbls) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(fspick_tbls)' $(beauty_uapi_linux_dir) > $@ + +fsconfig_arrays := $(beauty_outdir)/fsconfig_arrays.c +fsconfig_tbls := $(srctree)/tools/perf/trace/beauty/fsconfig.sh + +$(fsconfig_arrays): $(beauty_uapi_linux_dir)/mount.h $(fsconfig_tbls) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(fsconfig_tbls)' $(beauty_uapi_linux_dir) > $@ + +pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c +asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/ +pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh + +$(pkey_alloc_access_rights_array): $(asm_generic_hdr_dir)/mman-common.h $(pkey_alloc_access_rights_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(pkey_alloc_access_rights_tbl)' $(asm_generic_hdr_dir) > $@ + +sndrv_ctl_ioctl_array := $(beauty_ioctl_outdir)/sndrv_ctl_ioctl_array.c +sndrv_ctl_hdr_dir := $(srctree)/tools/include/uapi/sound +sndrv_ctl_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_ctl_ioctl.sh + +$(sndrv_ctl_ioctl_array): $(beauty_uapi_sound_dir)/asound.h $(sndrv_ctl_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(sndrv_ctl_ioctl_tbl)' $(beauty_uapi_sound_dir) > $@ + +sndrv_pcm_ioctl_array := $(beauty_ioctl_outdir)/sndrv_pcm_ioctl_array.c +sndrv_pcm_hdr_dir := $(srctree)/tools/include/uapi/sound +sndrv_pcm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/sndrv_pcm_ioctl.sh + +$(sndrv_pcm_ioctl_array): $(beauty_uapi_sound_dir)/asound.h $(sndrv_pcm_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(sndrv_pcm_ioctl_tbl)' $(beauty_uapi_sound_dir) > $@ + +kcmp_type_array := $(beauty_outdir)/kcmp_type_array.c +kcmp_hdr_dir := $(srctree)/tools/include/uapi/linux/ +kcmp_type_tbl := $(srctree)/tools/perf/trace/beauty/kcmp_type.sh + +$(kcmp_type_array): $(kcmp_hdr_dir)/kcmp.h $(kcmp_type_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(kcmp_type_tbl)' $(kcmp_hdr_dir) > $@ + +kvm_ioctl_array := $(beauty_ioctl_outdir)/kvm_ioctl_array.c +kvm_hdr_dir := $(srctree)/tools/include/uapi/linux +kvm_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/kvm_ioctl.sh + +$(kvm_ioctl_array): $(kvm_hdr_dir)/kvm.h $(kvm_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(kvm_ioctl_tbl)' $(kvm_hdr_dir) > $@ + +socket_arrays := $(beauty_outdir)/socket.c +socket_tbl := $(srctree)/tools/perf/trace/beauty/socket.sh + +$(socket_arrays): $(linux_uapi_dir)/in.h $(beauty_linux_dir)/socket.h $(socket_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(socket_tbl)' $(linux_uapi_dir) $(beauty_linux_dir) > $@ + +sockaddr_arrays := $(beauty_outdir)/sockaddr.c +sockaddr_tbl := $(srctree)/tools/perf/trace/beauty/sockaddr.sh + +$(sockaddr_arrays): $(beauty_linux_dir)/socket.h $(sockaddr_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(sockaddr_tbl)' $(beauty_linux_dir) > $@ + +vhost_virtio_ioctl_array := $(beauty_ioctl_outdir)/vhost_virtio_ioctl_array.c +vhost_virtio_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/vhost_virtio_ioctl.sh + +$(vhost_virtio_ioctl_array): $(beauty_uapi_linux_dir)/vhost.h $(vhost_virtio_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(vhost_virtio_ioctl_tbl)' $(beauty_uapi_linux_dir) > $@ + +perf_ioctl_array := $(beauty_ioctl_outdir)/perf_ioctl_array.c +perf_hdr_dir := $(srctree)/tools/include/uapi/linux +perf_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/perf_ioctl.sh + +$(perf_ioctl_array): $(perf_hdr_dir)/perf_event.h $(perf_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(perf_ioctl_tbl)' $(perf_hdr_dir) > $@ + +madvise_behavior_array := $(beauty_outdir)/madvise_behavior_array.c +madvise_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/ +madvise_behavior_tbl := $(srctree)/tools/perf/trace/beauty/madvise_behavior.sh + +$(madvise_behavior_array): $(madvise_hdr_dir)/mman-common.h $(madvise_behavior_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(madvise_behavior_tbl)' $(madvise_hdr_dir) > $@ + +mmap_flags_array := $(beauty_outdir)/mmap_flags_array.c +mmap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mmap_flags.sh + +$(mmap_flags_array): $(linux_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(mmap_flags_tbl)' $(linux_uapi_dir) $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ + +mremap_flags_array := $(beauty_outdir)/mremap_flags_array.c +mremap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mremap_flags.sh + +$(mremap_flags_array): $(linux_uapi_dir)/mman.h $(mremap_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(mremap_flags_tbl)' $(linux_uapi_dir) > $@ + +mount_flags_array := $(beauty_outdir)/mount_flags_array.c +mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.sh + +$(mount_flags_array): $(beauty_uapi_linux_dir)/mount.h $(mount_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(mount_flags_tbl)' $(beauty_uapi_linux_dir) > $@ + +move_mount_flags_array := $(beauty_outdir)/move_mount_flags_array.c +move_mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/move_mount_flags.sh + +$(move_mount_flags_array): $(beauty_uapi_linux_dir)/mount.h $(move_mount_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(move_mount_flags_tbl)' $(beauty_uapi_linux_dir) > $@ + +mmap_prot_array := $(beauty_outdir)/mmap_prot_array.c +mmap_prot_tbl := $(srctree)/tools/perf/trace/beauty/mmap_prot.sh + +$(mmap_prot_array): $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_prot_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(mmap_prot_tbl)' $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ + +prctl_option_array := $(beauty_outdir)/prctl_option_array.c +prctl_option_tbl := $(srctree)/tools/perf/trace/beauty/prctl_option.sh + +$(prctl_option_array): $(beauty_uapi_linux_dir)/prctl.h $(prctl_option_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(prctl_option_tbl)' $(beauty_uapi_linux_dir) > $@ + +usbdevfs_ioctl_array := $(beauty_ioctl_outdir)/usbdevfs_ioctl_array.c +usbdevfs_ioctl_tbl := $(srctree)/tools/perf/trace/beauty/usbdevfs_ioctl.sh + +$(usbdevfs_ioctl_array): $(beauty_uapi_linux_dir)/usbdevice_fs.h $(usbdevfs_ioctl_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(usbdevfs_ioctl_tbl)' $(beauty_uapi_linux_dir) > $@ + +x86_arch_prctl_code_array := $(beauty_outdir)/x86_arch_prctl_code_array.c +x86_arch_prctl_code_tbl := $(srctree)/tools/perf/trace/beauty/x86_arch_prctl.sh + +$(x86_arch_prctl_code_array): $(beauty_x86_arch_asm_uapi_dir)/prctl.h $(x86_arch_prctl_code_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(x86_arch_prctl_code_tbl)' $(beauty_x86_arch_asm_uapi_dir) > $@ + + +rename_flags_array := $(beauty_outdir)/rename_flags_array.c +rename_flags_tbl := $(srctree)/tools/perf/trace/beauty/rename_flags.sh + +$(rename_flags_array): $(beauty_uapi_linux_dir)/fs.h $(rename_flags_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(rename_flags_tbl)' $(beauty_uapi_linux_dir) > $@ + + +statx_mask_array := $(beauty_outdir)/statx_mask_array.c +statx_mask_tbl := $(srctree)/tools/perf/trace/beauty/statx_mask.sh + +$(statx_mask_array): $(beauty_uapi_linux_dir)/stat.h $(statx_mask_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(statx_mask_tbl)' $(beauty_uapi_linux_dir) > $@ + +sync_file_range_arrays := $(beauty_outdir)/sync_file_range_arrays.c +sync_file_range_tbls := $(srctree)/tools/perf/trace/beauty/sync_file_range.sh + +$(sync_file_range_arrays): $(beauty_uapi_linux_dir)/fs.h $(sync_file_range_tbls) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(sync_file_range_tbls)' $(beauty_uapi_linux_dir) > $@ + +# --- Precise Local Prerequisites Binding --- +$(OUTPUT)trace/beauty/syscalltbl.o: $(syscall_array) +$(OUTPUT)trace/beauty/fsconfig.o: $(fsconfig_arrays) +$(OUTPUT)trace/beauty/clone.o: $(clone_flags_array) +$(OUTPUT)trace/beauty/fs_at_flags.o: $(fs_at_flags_array) +$(OUTPUT)trace/beauty/fsmount.o: $(fsmount_arrays) +$(OUTPUT)trace/beauty/fspick.o: $(fspick_arrays) +$(OUTPUT)trace/beauty/ioctl.o: $(drm_ioctl_array) $(sndrv_pcm_ioctl_array) $(sndrv_ctl_ioctl_array) $(kvm_ioctl_array) $(vhost_virtio_ioctl_array) $(perf_ioctl_array) $(usbdevfs_ioctl_array) +$(OUTPUT)trace/beauty/kcmp.o: $(kcmp_type_array) +$(OUTPUT)trace/beauty/mmap.o: $(mmap_prot_array) $(mmap_flags_array) $(mremap_flags_array) $(madvise_behavior_array) +$(OUTPUT)trace/beauty/mount_flags.o: $(mount_flags_array) +$(OUTPUT)trace/beauty/move_mount.o: $(move_mount_flags_array) +$(OUTPUT)trace/beauty/pkey_alloc.o: $(pkey_alloc_access_rights_array) +$(OUTPUT)trace/beauty/prctl.o: $(prctl_option_array) +$(OUTPUT)trace/beauty/renameat.o: $(rename_flags_array) +$(OUTPUT)trace/beauty/sockaddr.o: $(sockaddr_arrays) +$(OUTPUT)trace/beauty/socket.o: $(socket_arrays) +$(OUTPUT)trace/beauty/statx.o: $(statx_mask_array) +$(OUTPUT)trace/beauty/sync_file_range.o: $(sync_file_range_arrays) +$(OUTPUT)trace/beauty/arch_prctl.o: $(x86_arch_prctl_code_array) + +arch_errno_name_array := $(beauty_outdir)/arch_errno_name_array.c +arch_errno_hdr_dir := $(srctree)/tools +arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh + +$(arch_errno_name_array): $(arch_errno_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(arch_errno_tbl)' '$(patsubst -%,,$(CC))' $(arch_errno_hdr_dir) > $@ + +$(OUTPUT)trace/beauty/arch_errno_names.o: $(arch_errno_name_array) diff --git a/tools/perf/trace/beauty/arch_errno_names.c b/tools/perf/trace/beauty/arch_errno_names.c index ede031c3a9e0..156c6537e747 100644 --- a/tools/perf/trace/beauty/arch_errno_names.c +++ b/tools/perf/trace/beauty/arch_errno_names.c @@ -1 +1,3 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "util/env.h" #include "trace/beauty/generated/arch_errno_name_array.c" diff --git a/tools/perf/trace/beauty/arch_errno_names.sh b/tools/perf/trace/beauty/arch_errno_names.sh index b22890b8d272..d48d8561a7bb 100755 --- a/tools/perf/trace/beauty/arch_errno_names.sh +++ b/tools/perf/trace/beauty/arch_errno_names.sh @@ -57,7 +57,7 @@ create_arch_errno_table_func() archlist="$1" default="$2" - printf 'static arch_syscalls__strerrno_t *\n' + printf 'arch_syscalls__strerrno_t *\n' printf 'arch_syscalls__strerrno_function(const char *arch)\n' printf '{\n' for arch in $archlist; do diff --git a/tools/perf/trace/beauty/beauty.h b/tools/perf/trace/beauty/beauty.h index 0a07ad158f87..931c4a80fea9 100644 --- a/tools/perf/trace/beauty/beauty.h +++ b/tools/perf/trace/beauty/beauty.h @@ -35,6 +35,8 @@ bool strarray__strtoul(struct strarray *sa, char *bf, size_t size, u64 *ret); bool strarray__strtoul_flags(struct strarray *sa, char *bf, size_t size, u64 *ret); struct trace; +bool trace__show_zeros(const struct trace *trace); +struct machine *trace__host(const struct trace *trace); struct thread; struct file { @@ -265,4 +267,62 @@ size_t open__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool sh void syscall_arg__set_ret_scnprintf(struct syscall_arg *arg, size_t (*ret_scnprintf)(char *bf, size_t size, struct syscall_arg *arg)); +extern struct strarray strarray__fsconfig_cmds; + +size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_EFD_FLAGS syscall_arg__scnprintf_eventfd_flags + +size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_FUTEX_OP syscall_arg__scnprintf_futex_op + +size_t syscall_arg__scnprintf_futex_val3(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_FUTEX_VAL3 syscall_arg__scnprintf_futex_val3 + +size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot + +extern struct strarray strarray__mmap_flags; + +size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags + +size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_MREMAP_FLAGS syscall_arg__scnprintf_mremap_flags + +size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior + +size_t syscall_arg__scnprintf_mode_t(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_MODE_T syscall_arg__scnprintf_mode_t + +size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_MSG_FLAGS syscall_arg__scnprintf_msg_flags + +size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_PERF_FLAGS syscall_arg__scnprintf_perf_flags + +size_t syscall_arg__scnprintf_perf_event_attr(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_PERF_ATTR syscall_arg__scnprintf_perf_event_attr +#define SCA_PERF_ATTR_FROM_USER(argname) \ + { .scnprintf = SCA_PERF_ATTR, \ + .from_user = true, } + +size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_SCHED_POLICY syscall_arg__scnprintf_sched_policy + +size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_SECCOMP_OP syscall_arg__scnprintf_seccomp_op + +size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags + +size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_SIGNUM syscall_arg__scnprintf_signum + +size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_SK_TYPE syscall_arg__scnprintf_socket_type + +size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_WAITID_OPTIONS syscall_arg__scnprintf_waitid_options + #endif /* _PERF_TRACE_BEAUTY_H */ diff --git a/tools/perf/trace/beauty/eventfd.c b/tools/perf/trace/beauty/eventfd.c index 4bab106213c6..3fc552c9c360 100644 --- a/tools/perf/trace/beauty/eventfd.c +++ b/tools/perf/trace/beauty/eventfd.c @@ -11,7 +11,9 @@ #define EFD_CLOEXEC 02000000 #endif -static size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "EFD_"; @@ -36,4 +38,4 @@ static size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct return printed; } -#define SCA_EFD_FLAGS syscall_arg__scnprintf_eventfd_flags + diff --git a/tools/perf/trace/beauty/fsconfig.c b/tools/perf/trace/beauty/fsconfig.c new file mode 100644 index 000000000000..98aa05315673 --- /dev/null +++ b/tools/perf/trace/beauty/fsconfig.c @@ -0,0 +1,5 @@ +// SPDX-License-Identifier: LGPL-2.1 +#include "trace/beauty/beauty.h" +#include "trace/beauty/generated/fsconfig_arrays.c" + +DEFINE_STRARRAY(fsconfig_cmds, "FSCONFIG_"); diff --git a/tools/perf/trace/beauty/futex_op.c b/tools/perf/trace/beauty/futex_op.c index 00365156782b..fb627780d381 100644 --- a/tools/perf/trace/beauty/futex_op.c +++ b/tools/perf/trace/beauty/futex_op.c @@ -17,7 +17,9 @@ #define FUTEX_CLOCK_REALTIME 256 #endif -static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "FUTEX_"; @@ -60,4 +62,4 @@ static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct sysc return printed; } -#define SCA_FUTEX_OP syscall_arg__scnprintf_futex_op + diff --git a/tools/perf/trace/beauty/futex_val3.c b/tools/perf/trace/beauty/futex_val3.c index 9114f7620571..d4d2fb117d39 100644 --- a/tools/perf/trace/beauty/futex_val3.c +++ b/tools/perf/trace/beauty/futex_val3.c @@ -5,7 +5,9 @@ #define FUTEX_BITSET_MATCH_ANY 0xffffffff #endif -static size_t syscall_arg__scnprintf_futex_val3(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_futex_val3(char *bf, size_t size, struct syscall_arg *arg) { const char *prefix = "FUTEX_BITSET_"; unsigned int bitset = arg->val; @@ -16,4 +18,4 @@ static size_t syscall_arg__scnprintf_futex_val3(char *bf, size_t size, struct sy return scnprintf(bf, size, "%#xd", bitset); } -#define SCA_FUTEX_VAL3 syscall_arg__scnprintf_futex_val3 + diff --git a/tools/perf/trace/beauty/mmap.c b/tools/perf/trace/beauty/mmap.c index 3c5e97b93dd5..f1a1012fd2a0 100644 --- a/tools/perf/trace/beauty/mmap.c +++ b/tools/perf/trace/beauty/mmap.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: LGPL-2.1 #include <linux/log2.h> +#include "trace/beauty/beauty.h" #include "trace/beauty/generated/mmap_prot_array.c" static DEFINE_STRARRAY(mmap_prot, "PROT_"); @@ -8,8 +9,7 @@ static size_t mmap__scnprintf_prot(unsigned long prot, char *bf, size_t size, bo { return strarray__scnprintf_flags(&strarray__mmap_prot, bf, size, show_prefix, prot); } - -static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, struct syscall_arg *arg) +size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, struct syscall_arg *arg) { unsigned long prot = arg->val; @@ -19,18 +19,18 @@ static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, struct sys return mmap__scnprintf_prot(prot, bf, size, arg->show_string_prefix); } -#define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot + #include "trace/beauty/generated/mmap_flags_array.c" -static DEFINE_STRARRAY(mmap_flags, "MAP_"); +DEFINE_STRARRAY(mmap_flags, "MAP_"); static size_t mmap__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix) { return strarray__scnprintf_flags(&strarray__mmap_flags, bf, size, show_prefix, flags); } -static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, - struct syscall_arg *arg) +size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, + struct syscall_arg *arg) { unsigned long flags = arg->val; @@ -40,7 +40,7 @@ static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size, return mmap__scnprintf_flags(flags, bf, size, arg->show_string_prefix); } -#define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags + #include "trace/beauty/generated/mremap_flags_array.c" static DEFINE_STRARRAY(mremap_flags, "MREMAP_"); @@ -50,7 +50,7 @@ static size_t mremap__scnprintf_flags(unsigned long flags, char *bf, size_t size return strarray__scnprintf_flags(&strarray__mremap_flags, bf, size, show_prefix, flags); } -static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, struct syscall_arg *arg) +size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, struct syscall_arg *arg) { unsigned long flags = arg->val; @@ -60,7 +60,7 @@ static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, struct return mremap__scnprintf_flags(flags, bf, size, arg->show_string_prefix); } -#define SCA_MREMAP_FLAGS syscall_arg__scnprintf_mremap_flags + static size_t madvise__scnprintf_behavior(int behavior, char *bf, size_t size) { @@ -73,10 +73,10 @@ static size_t madvise__scnprintf_behavior(int behavior, char *bf, size_t size) return scnprintf(bf, size, "%#", behavior); } -static size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size, - struct syscall_arg *arg) +size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size, + struct syscall_arg *arg) { return madvise__scnprintf_behavior(arg->val, bf, size); } -#define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior + diff --git a/tools/perf/trace/beauty/mode_t.c b/tools/perf/trace/beauty/mode_t.c index 29a8fadfb7f9..7d7f89229513 100644 --- a/tools/perf/trace/beauty/mode_t.c +++ b/tools/perf/trace/beauty/mode_t.c @@ -20,7 +20,9 @@ #define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) #endif -static size_t syscall_arg__scnprintf_mode_t(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_mode_t(char *bf, size_t size, struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "S_"; @@ -68,4 +70,4 @@ static size_t syscall_arg__scnprintf_mode_t(char *bf, size_t size, struct syscal return printed; } -#define SCA_MODE_T syscall_arg__scnprintf_mode_t + diff --git a/tools/perf/trace/beauty/msg_flags.c b/tools/perf/trace/beauty/msg_flags.c index 2da581ff0c80..5721b2bee99f 100644 --- a/tools/perf/trace/beauty/msg_flags.c +++ b/tools/perf/trace/beauty/msg_flags.c @@ -27,8 +27,10 @@ # define MSG_CMSG_CLOEXEC 0x40000000 #endif -static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, - struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, + struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "MSG_"; @@ -73,4 +75,4 @@ static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, return printed; } -#define SCA_MSG_FLAGS syscall_arg__scnprintf_msg_flags + diff --git a/tools/perf/trace/beauty/open_flags.c b/tools/perf/trace/beauty/open_flags.c index 78f6566ef110..a0396f9732ad 100644 --- a/tools/perf/trace/beauty/open_flags.c +++ b/tools/perf/trace/beauty/open_flags.c @@ -2,6 +2,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include "trace/beauty/beauty.h" #ifndef O_DIRECT #define O_DIRECT 00040000 diff --git a/tools/perf/trace/beauty/perf_event_open.c b/tools/perf/trace/beauty/perf_event_open.c index 9f1ed989c775..d4e0f7816423 100644 --- a/tools/perf/trace/beauty/perf_event_open.c +++ b/tools/perf/trace/beauty/perf_event_open.c @@ -1,4 +1,7 @@ // SPDX-License-Identifier: LGPL-2.1 +#include <linux/perf_event.h> +#include "util/evsel_fprintf.h" + #ifndef PERF_FLAG_FD_NO_GROUP # define PERF_FLAG_FD_NO_GROUP (1UL << 0) #endif @@ -15,8 +18,10 @@ # define PERF_FLAG_FD_CLOEXEC (1UL << 3) /* O_CLOEXEC */ #endif -static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, - struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, + struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "PERF_"; @@ -43,7 +48,7 @@ static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size, return printed; } -#define SCA_PERF_FLAGS syscall_arg__scnprintf_perf_flags + struct attr_fprintf_args { size_t size, printed; @@ -76,10 +81,11 @@ static size_t perf_event_attr___scnprintf(struct perf_event_attr *attr, char *bf static size_t syscall_arg__scnprintf_augmented_perf_event_attr(struct syscall_arg *arg, char *bf, size_t size) { - return perf_event_attr___scnprintf((void *)arg->augmented.args->value, bf, size, arg->trace->show_zeros); + return perf_event_attr___scnprintf((void *)arg->augmented.args->value, bf, size, + trace__show_zeros(arg->trace)); } -static size_t syscall_arg__scnprintf_perf_event_attr(char *bf, size_t size, struct syscall_arg *arg) +size_t syscall_arg__scnprintf_perf_event_attr(char *bf, size_t size, struct syscall_arg *arg) { if (arg->augmented.args) return syscall_arg__scnprintf_augmented_perf_event_attr(arg, bf, size); @@ -87,8 +93,4 @@ static size_t syscall_arg__scnprintf_perf_event_attr(char *bf, size_t size, stru return scnprintf(bf, size, "%#lx", arg->val); } -#define SCA_PERF_ATTR syscall_arg__scnprintf_perf_event_attr -// 'argname' is just documentational at this point, to remove the previous comment with that info -#define SCA_PERF_ATTR_FROM_USER(argname) \ - { .scnprintf = SCA_PERF_ATTR, \ - .from_user = true, } + diff --git a/tools/perf/trace/beauty/pid.c b/tools/perf/trace/beauty/pid.c index 8f9c9950f8ba..cca4a3a5d9bd 100644 --- a/tools/perf/trace/beauty/pid.c +++ b/tools/perf/trace/beauty/pid.c @@ -1,11 +1,14 @@ // SPDX-License-Identifier: LGPL-2.1 +#include "trace/beauty/beauty.h" +#include "util/machine.h" +#include "util/thread.h" size_t syscall_arg__scnprintf_pid(char *bf, size_t size, struct syscall_arg *arg) { int pid = arg->val; struct trace *trace = arg->trace; size_t printed = scnprintf(bf, size, "%d", pid); - struct thread *thread = machine__findnew_thread(trace->host, pid, pid); + struct thread *thread = machine__findnew_thread(trace__host(trace), pid, pid); if (thread != NULL) { if (!thread__comm_set(thread)) diff --git a/tools/perf/trace/beauty/sched_policy.c b/tools/perf/trace/beauty/sched_policy.c index 68aa59eeed8d..7f7928d396be 100644 --- a/tools/perf/trace/beauty/sched_policy.c +++ b/tools/perf/trace/beauty/sched_policy.c @@ -14,8 +14,10 @@ #define SCHED_RESET_ON_FORK 0x40000000 #endif -static size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size, - struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size, + struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "SCHED_"; @@ -47,4 +49,4 @@ static size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size, return printed; } -#define SCA_SCHED_POLICY syscall_arg__scnprintf_sched_policy + diff --git a/tools/perf/trace/beauty/seccomp.c b/tools/perf/trace/beauty/seccomp.c index 637722e2796b..b04555a364e2 100644 --- a/tools/perf/trace/beauty/seccomp.c +++ b/tools/perf/trace/beauty/seccomp.c @@ -6,7 +6,9 @@ #define SECCOMP_SET_MODE_FILTER 1 #endif -static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "SECCOMP_SET_MODE_"; @@ -24,14 +26,14 @@ static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct sy return printed; } -#define SCA_SECCOMP_OP syscall_arg__scnprintf_seccomp_op + #ifndef SECCOMP_FILTER_FLAG_TSYNC #define SECCOMP_FILTER_FLAG_TSYNC 1 #endif -static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size, - struct syscall_arg *arg) +size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size, + struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "SECCOMP_FILTER_FLAG_"; @@ -52,4 +54,4 @@ static size_t syscall_arg__scnprintf_seccomp_flags(char *bf, size_t size, return printed; } -#define SCA_SECCOMP_FLAGS syscall_arg__scnprintf_seccomp_flags + diff --git a/tools/perf/trace/beauty/signum.c b/tools/perf/trace/beauty/signum.c index 21220c56500a..0303a6e298c8 100644 --- a/tools/perf/trace/beauty/signum.c +++ b/tools/perf/trace/beauty/signum.c @@ -1,7 +1,9 @@ // SPDX-License-Identifier: LGPL-2.1 #include <signal.h> -static size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "SIG"; @@ -54,4 +56,4 @@ static size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscal return scnprintf(bf, size, "%#x", sig); } -#define SCA_SIGNUM syscall_arg__scnprintf_signum + diff --git a/tools/perf/trace/beauty/socket_type.c b/tools/perf/trace/beauty/socket_type.c index bed8d5761ca8..c116b61a6ea9 100644 --- a/tools/perf/trace/beauty/socket_type.c +++ b/tools/perf/trace/beauty/socket_type.c @@ -18,7 +18,9 @@ #define SOCK_TYPE_MASK 0xf #endif -static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "SOCK_"; @@ -60,4 +62,4 @@ static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct s return printed; } -#define SCA_SK_TYPE syscall_arg__scnprintf_socket_type + diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/trace/beauty/syscalltbl.c similarity index 100% rename from tools/perf/util/syscalltbl.c rename to tools/perf/trace/beauty/syscalltbl.c diff --git a/tools/perf/util/syscalltbl.h b/tools/perf/trace/beauty/syscalltbl.h similarity index 100% rename from tools/perf/util/syscalltbl.h rename to tools/perf/trace/beauty/syscalltbl.h diff --git a/tools/perf/trace/beauty/tracepoints/Build b/tools/perf/trace/beauty/tracepoints/Build index e35087fdd108..392677319c6a 100644 --- a/tools/perf/trace/beauty/tracepoints/Build +++ b/tools/perf/trace/beauty/tracepoints/Build @@ -1,2 +1,24 @@ perf-y += x86_irq_vectors.o perf-y += x86_msr.o + +# --- Local Encapsulated Tracepoint Rules --- +beauty_outdir := $(OUTPUT)trace/beauty/generated +beauty_arch_asm_dir := $(srctree)/tools/perf/trace/beauty/arch/x86/include/asm/ +x86_arch_asm_dir := $(srctree)/tools/arch/x86/include/asm/ + +x86_arch_irq_vectors_array := $(beauty_outdir)/x86_arch_irq_vectors_array.c +x86_arch_irq_vectors_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_irq_vectors.sh + +$(x86_arch_irq_vectors_array): $(beauty_arch_asm_dir)/irq_vectors.h $(x86_arch_irq_vectors_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(x86_arch_irq_vectors_tbl)' $(beauty_arch_asm_dir) > $@ + +x86_arch_MSRs_array := $(beauty_outdir)/x86_arch_MSRs_array.c +x86_arch_MSRs_tbl := $(srctree)/tools/perf/trace/beauty/tracepoints/x86_msr.sh + +$(x86_arch_MSRs_array): $(x86_arch_asm_dir)/msr-index.h $(x86_arch_MSRs_tbl) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(SHELL) '$(x86_arch_MSRs_tbl)' $(x86_arch_asm_dir) > $@ + +$(OUTPUT)trace/beauty/tracepoints/x86_irq_vectors.o: $(x86_arch_irq_vectors_array) +$(OUTPUT)trace/beauty/tracepoints/x86_msr.o: $(x86_arch_MSRs_array) diff --git a/tools/perf/trace/beauty/waitid_options.c b/tools/perf/trace/beauty/waitid_options.c index d4d10b33ba0e..b3bd21162d6b 100644 --- a/tools/perf/trace/beauty/waitid_options.c +++ b/tools/perf/trace/beauty/waitid_options.c @@ -2,8 +2,10 @@ #include <sys/types.h> #include <sys/wait.h> -static size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size, - struct syscall_arg *arg) +#include "trace/beauty/beauty.h" + +size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size, + struct syscall_arg *arg) { bool show_prefix = arg->show_string_prefix; const char *prefix = "W"; @@ -26,4 +28,4 @@ static size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size, return printed; } -#define SCA_WAITID_OPTIONS syscall_arg__scnprintf_waitid_options + diff --git a/tools/perf/util/Build b/tools/perf/util/Build index 70cc91d00804..abc9a2926e85 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -75,7 +75,7 @@ perf-util-y += sample.o perf-util-y += sample-raw.o perf-util-y += s390-sample-raw.o perf-util-y += amd-sample-raw.o -perf-util-$(CONFIG_TRACE) += syscalltbl.o + perf-util-y += ordered-events.o perf-util-y += namespaces.o perf-util-y += comm.o @@ -441,3 +441,5 @@ $(OUTPUT)%.pylint_log: % $(Q)$(call echo-cmd,test)pylint "$<" > $@ || (cat $@ && rm $@ && false) perf-util-y += $(PYLINT_TEST_LOGS) + + diff --git a/tools/perf/util/bpf-trace-summary.c b/tools/perf/util/bpf-trace-summary.c index cf6e1e4402d5..9a31dbf06cbb 100644 --- a/tools/perf/util/bpf-trace-summary.c +++ b/tools/perf/util/bpf-trace-summary.c @@ -6,7 +6,7 @@ #include <stdlib.h> #include "dwarf-regs.h" /* for EM_HOST */ -#include "syscalltbl.h" +#include "trace/beauty/syscalltbl.h" #include "util/cgroup.h" #include "util/hashmap.h" #include "util/trace.h" diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index 1e54e2c86360..e694ae14686a 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -635,9 +635,7 @@ const char *perf_env__arch(struct perf_env *env) return normalize_arch(arch_name); } -#if defined(HAVE_LIBTRACEEVENT) -#include "trace/beauty/arch_errno_names.c" -#endif + const char *perf_env__arch_strerrno(struct perf_env *env __maybe_unused, int err __maybe_unused) { diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h index c7052ac1f856..739d884fc236 100644 --- a/tools/perf/util/env.h +++ b/tools/perf/util/env.h @@ -189,6 +189,7 @@ void cpu_cache_level__free(struct cpu_cache_level *cache); const char *perf_env__arch(struct perf_env *env); const char *perf_env__arch_strerrno(struct perf_env *env, int err); +arch_syscalls__strerrno_t *arch_syscalls__strerrno_function(const char *arch); const char *perf_env__cpuid(struct perf_env *env); const char *perf_env__raw_arch(struct perf_env *env); int perf_env__nr_cpus_avail(struct perf_env *env); -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 06/18] perf build: Decouple pmu-events from prepare umbrella target 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (4 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 05/18] perf trace beauty: Make beauty generated C code standalone .o files Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 07/18] perf build: Remove empty archheaders target Ian Rogers ` (11 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song Currently, the $(LIBPMU_EVENTS_IN) sub-make depends on the massive "prepare" umbrella target. Because "prepare" depends on external libraries (libapi, libperf, etc.) as well as dozens of generated headers, make completely serializes the launch of the pmu-events sub-make behind some of those unrelated prerequisites. Since pmu-events is a large compilation unit, unblock its startup by binding it directly to only $(LIBPERF) instead of prepare. This allows background python generation scripts to overlap simultaneously with the rest of the build. Testing a parallel build (make -j28 clean all) shows improvements: Before: real 0m27.642s user 2m32.356s sys 0m26.683s After: real 0m22.254s user 2m32.810s sys 0m24.646s This reclaims over 5 full seconds of build latency (~19.5% overall reduction) by elevating average CPU concurrency from ~5.5 active cores up to ~8 active cores. Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index c81797ceec42..c66af4c825fd 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -550,7 +550,7 @@ build := -f $(srctree)/tools/build/Makefile.build dir=. obj $(PERF_IN): prepare FORCE $(Q)$(MAKE) $(build)=perf -$(LIBPMU_EVENTS_IN): FORCE prepare +$(LIBPMU_EVENTS_IN): FORCE $(LIBPERF) $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=pmu-events obj=pmu-events $(LIBPMU_EVENTS): $(LIBPMU_EVENTS_IN) -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 07/18] perf build: Remove empty archheaders target 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (5 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 06/18] perf build: Decouple pmu-events from prepare umbrella target Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 08/18] perf build: Move BPF skeleton generation out of Makefile.perf Ian Rogers ` (10 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song Remove empty target that doesn't do anything. Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index c66af4c825fd..24581941e912 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -627,7 +627,7 @@ endif __build-dir = $(subst $(OUTPUT),,$(dir $@)) build-dir = $(or $(__build-dir),.) -prepare: $(OUTPUT)PERF-VERSION-FILE archheaders \ +prepare: $(OUTPUT)PERF-VERSION-FILE \ arm64-sysreg-defs \ $(LIBAPI) \ $(LIBPERF) \ @@ -1070,7 +1070,7 @@ FORCE: .PHONY: all install clean config-clean strip install-gtk .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare -.PHONY: archheaders python_perf_target +.PHONY: python_perf_target endif # force_fixdep -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 08/18] perf build: Move BPF skeleton generation out of Makefile.perf 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (6 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 07/18] perf build: Remove empty archheaders target Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 09/18] perf build: Encapsulate vmlinux.h and bpftool in bpf_skel.mak Ian Rogers ` (9 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song Currently, the top-level Makefile.perf defines a massive global bpf-skel umbrella target that pre-compiles all 12+ BPF skeletons (%.skel.h) upfront before launching sub-makes. This forces unrelated sub-makes to serialize behind bpftool and clang BPF target evaluations, causing parallel build bottlenecks. Furthermore, bench_uprobe.bpf.c lived inside util/bpf_skel/, breaking conceptual directory encapsulation since it is consumed purely by bench/uprobe.c. Refactor the BPF skeletons to better achieve directory isolation: 1. Move tools/perf/util/bpf_skel/bench_uprobe.bpf.c directly into tools/perf/bench/bpf_skel/. 2. Extract the skeleton generation infrastructure out of Makefile.perf into a shared inclusion file tools/perf/bpf_skel.mak. 3. Include bpf_skel.mak locally inside tools/perf/util/Build and tools/perf/bench/Build and bind precise local prerequisites. 4. Safely synchronize the shared bpftool bootstrap and vmlinux.h targets via the conditional prepare: umbrella to avoid parallel sub-make races, while evaluating the actual skeletons completely locally on demand. A later patch will move these targets into bpf_skel.mak. 5. Export CLANG from the global Makefile to ensure accurate tool propagation. 6. Clean up Makefile.perf by stripping the global bpf-skel umbrella target and its SKELETONS list. While removing code from Makefile.perf generally helps build performance, the impact here is minimal. The main motivation for the change is to better encapsulate things in the build and simplify Makefile.perf that has around 50 lines removed. Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 59 ++----------------- tools/perf/bench/Build | 6 ++ .../bpf_skel/bench_uprobe.bpf.c | 0 tools/perf/bench/uprobe.c | 2 +- tools/perf/bpf_skel.mak | 55 +++++++++++++++++ tools/perf/util/Build | 15 ++++- 6 files changed, 80 insertions(+), 57 deletions(-) rename tools/perf/{util => bench}/bpf_skel/bench_uprobe.bpf.c (100%) create mode 100644 tools/perf/bpf_skel.mak diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 24581941e912..d4fc10f36781 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -274,7 +274,7 @@ ifeq ($(PYLINT),1) PYLINT := $(shell which pylint 2> /dev/null) endif -export srctree OUTPUT RM CC CXX RUSTC LD AR CFLAGS CXXFLAGS RUST_FLAGS V BISON FLEX AWK +export srctree OUTPUT RM CC CXX RUSTC CLANG LD AR CFLAGS CXXFLAGS RUST_FLAGS V BISON FLEX AWK LIBBPF export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT include $(srctree)/tools/build/Makefile.include @@ -632,8 +632,7 @@ prepare: $(OUTPUT)PERF-VERSION-FILE \ $(LIBAPI) \ $(LIBPERF) \ $(LIBSUBCMD) \ - $(LIBSYMBOL) \ - bpf-skel + $(LIBSYMBOL) ifdef LIBBPF_STATIC prepare: $(LIBBPF) @@ -914,44 +913,13 @@ python-clean: SKEL_OUT := $(abspath $(OUTPUT)util/bpf_skel) SKEL_TMP_OUT := $(abspath $(SKEL_OUT)/.tmp) -SKELETONS := $(SKEL_OUT)/bpf_prog_profiler.skel.h -SKELETONS += $(SKEL_OUT)/bperf_leader.skel.h $(SKEL_OUT)/bperf_follower.skel.h -SKELETONS += $(SKEL_OUT)/bperf_cgroup.skel.h $(SKEL_OUT)/func_latency.skel.h -SKELETONS += $(SKEL_OUT)/off_cpu.skel.h $(SKEL_OUT)/lock_contention.skel.h -SKELETONS += $(SKEL_OUT)/kwork_trace.skel.h $(SKEL_OUT)/sample_filter.skel.h -SKELETONS += $(SKEL_OUT)/kwork_top.skel.h $(SKEL_OUT)/syscall_summary.skel.h -SKELETONS += $(SKEL_OUT)/bench_uprobe.skel.h -SKELETONS += $(SKEL_OUT)/augmented_raw_syscalls.skel.h $(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT): $(Q)$(MKDIR) -p $@ ifeq ($(CONFIG_PERF_BPF_SKEL),y) +prepare: $(BPFTOOL) $(SKEL_OUT)/vmlinux.h BPFTOOL := $(SKEL_TMP_OUT)/bootstrap/bpftool -# Get Clang's default includes on this system, as opposed to those seen by -# '--target=bpf'. This fixes "missing" files on some architectures/distros, -# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc. -# -# Use '-idirafter': Don't interfere with include mechanics except where the -# build would have failed anyways. -define get_sys_includes -$(shell $(1) $(2) -v -E - </dev/null 2>&1 \ - | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ -$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') -endef - -ifneq ($(CROSS_COMPILE),) -CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%)) -endif - -CLANG_OPTIONS = -Wall -CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) -BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES) -TOOLS_UAPI_INCLUDE := -I$(srctree)/tools/include/uapi - -ifneq ($(WERROR),0) - CLANG_OPTIONS += -Werror -endif $(BPFTOOL): | $(SKEL_TMP_OUT) $(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool \ @@ -993,29 +961,10 @@ else $(Q)cp "$(VMLINUX_H)" $@ endif -$(SKEL_TMP_OUT)/%.bpf.o: $(OUTPUT)PERF-VERSION-FILE util/bpf_skel/perf_version.h | $(SKEL_TMP_OUT) -$(SKEL_TMP_OUT)/%.bpf.o: util/bpf_skel/%.bpf.c $(LIBBPF) $(SKEL_OUT)/vmlinux.h - $(QUIET_CLANG)$(CLANG) -g -O2 -fno-stack-protector --target=bpf \ - $(CLANG_OPTIONS) $(EXTRA_BPF_FLAGS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \ - -include $(OUTPUT)PERF-VERSION-FILE -include util/bpf_skel/perf_version.h \ - -fms-extensions -Wno-microsoft-anon-tag \ - -c $(filter util/bpf_skel/%.bpf.c,$^) -o $@ - -$(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o | $(BPFTOOL) - $(QUIET_GENSKEL)$(BPFTOOL) gen skeleton $< > $@ - -bpf-skel: $(SKELETONS) - -.PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o - -else # CONFIG_PERF_BPF_SKEL - -bpf-skel: - endif # CONFIG_PERF_BPF_SKEL bpf-skel-clean: - $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS) $(SKEL_OUT)/vmlinux.h + $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKEL_OUT)/*.skel.h $(SKEL_OUT)/vmlinux.h $(OUTPUT)bench/bpf_skel/*.skel.h pmu-events-clean: ifeq ($(OUTPUT),) diff --git a/tools/perf/bench/Build b/tools/perf/bench/Build index b558ab98719f..67b76fe20ba6 100644 --- a/tools/perf/bench/Build +++ b/tools/perf/bench/Build @@ -24,3 +24,9 @@ perf-bench-$(CONFIG_X86_64) += mem-memcpy-x86-64-asm.o perf-bench-$(CONFIG_X86_64) += mem-memset-x86-64-asm.o perf-bench-$(CONFIG_NUMA) += numa.o + +ifeq ($(CONFIG_PERF_BPF_SKEL),y) +include $(srctree)/tools/perf/bpf_skel.mak + +$(OUTPUT)bench/uprobe.o: $(SKEL_OUT)/bench_uprobe.skel.h +endif diff --git a/tools/perf/util/bpf_skel/bench_uprobe.bpf.c b/tools/perf/bench/bpf_skel/bench_uprobe.bpf.c similarity index 100% rename from tools/perf/util/bpf_skel/bench_uprobe.bpf.c rename to tools/perf/bench/bpf_skel/bench_uprobe.bpf.c diff --git a/tools/perf/bench/uprobe.c b/tools/perf/bench/uprobe.c index 89697ff788ef..616873bca243 100644 --- a/tools/perf/bench/uprobe.c +++ b/tools/perf/bench/uprobe.c @@ -44,7 +44,7 @@ static const char * const bench_uprobe_usage[] = { }; #ifdef HAVE_BPF_SKEL -#include "bpf_skel/bench_uprobe.skel.h" +#include "bench/bpf_skel/bench_uprobe.skel.h" #define bench_uprobe__attach_uprobe(prog) \ skel->links.prog = bpf_program__attach_uprobe_opts(/*prog=*/skel->progs.prog, \ diff --git a/tools/perf/bpf_skel.mak b/tools/perf/bpf_skel.mak new file mode 100644 index 000000000000..bcb704d5af32 --- /dev/null +++ b/tools/perf/bpf_skel.mak @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: GPL-2.0 +# Shared BPF Skeleton Generator Rules + +include $(srctree)/tools/scripts/Makefile.include + +# Shared foundational tooling always lives in util/bpf_skel +SKEL_TOOL_OUT := $(abspath $(OUTPUT)util/bpf_skel) +SKEL_TOOL_TMP_OUT := $(abspath $(SKEL_TOOL_OUT)/.tmp) + +# Component specific output lives in $(dir)/bpf_skel +SKEL_OUT := $(abspath $(OUTPUT)$(dir)/bpf_skel) +SKEL_TMP_OUT := $(abspath $(SKEL_OUT)/.tmp) + +ifeq ($(CONFIG_PERF_BPF_SKEL),y) +BPFTOOL := $(SKEL_TOOL_TMP_OUT)/bootstrap/bpftool +VMLINUX_H := $(SKEL_TOOL_OUT)/vmlinux.h +bpf_skel_deps := $(BPFTOOL) $(VMLINUX_H) + +define get_sys_includes +$(shell $(1) $(2) -v -E - </dev/null 2>&1 \ + | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ +$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') +endef + +ifneq ($(CROSS_COMPILE),) +CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%)) +endif + +CLANG_OPTIONS = -Wall +CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) +LIBBPF_INCLUDE := $(abspath $(or $(OUTPUT),.))/libbpf/include +BPF_INCLUDE := -I$(SKEL_TMP_OUT)/.. -I$(SKEL_TOOL_OUT) -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES) +TOOLS_UAPI_INCLUDE := -I$(srctree)/tools/include/uapi + +ifneq ($(WERROR),0) + CLANG_OPTIONS += -Werror +endif + +# Consolidated Pattern rule for $(dir)/bpf_skel/ +$(SKEL_TMP_OUT)/%.bpf.o: $(srctree)/tools/perf/$(dir)/bpf_skel/%.bpf.c $(LIBBPF) $(VMLINUX_H) $(OUTPUT)PERF-VERSION-FILE util/bpf_skel/perf_version.h + $(call rule_mkdir) + $(QUIET_CLANG) + $(Q)$(CLANG) -g -O2 -fno-stack-protector --target=bpf \ + $(CLANG_OPTIONS) $(EXTRA_BPF_FLAGS) $(BPF_INCLUDE) $(TOOLS_UAPI_INCLUDE) \ + -include $(OUTPUT)PERF-VERSION-FILE -include util/bpf_skel/perf_version.h \ + -fms-extensions -Wno-microsoft-anon-tag \ + -c $< -o $@ + +$(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o $(BPFTOOL) + $(call rule_mkdir) + $(QUIET_GENSKEL) + $(Q)$(BPFTOOL) gen skeleton $< > $@ + +.PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o +endif # CONFIG_PERF_BPF_SKEL diff --git a/tools/perf/util/Build b/tools/perf/util/Build index abc9a2926e85..40c258ac99b9 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -442,4 +442,17 @@ $(OUTPUT)%.pylint_log: % perf-util-y += $(PYLINT_TEST_LOGS) - +ifeq ($(CONFIG_PERF_BPF_SKEL),y) +include $(srctree)/tools/perf/bpf_skel.mak + +$(OUTPUT)util/bpf_ftrace.o: $(SKEL_OUT)/func_latency.skel.h +$(OUTPUT)util/bpf-filter.o: $(SKEL_OUT)/sample_filter.skel.h +$(OUTPUT)util/bpf_kwork_top.o: $(SKEL_OUT)/kwork_top.skel.h +$(OUTPUT)util/bpf_off_cpu.o: $(SKEL_OUT)/off_cpu.skel.h +$(OUTPUT)util/bpf-trace-summary.o: $(SKEL_OUT)/syscall_summary.skel.h +$(OUTPUT)util/bpf_counter_cgroup.o: $(SKEL_OUT)/bperf_cgroup.skel.h +$(OUTPUT)util/bpf_trace_augment.o: $(SKEL_OUT)/augmented_raw_syscalls.skel.h +$(OUTPUT)util/bpf_counter.o: $(SKEL_OUT)/bpf_prog_profiler.skel.h $(SKEL_OUT)/bperf_leader.skel.h $(SKEL_OUT)/bperf_follower.skel.h +$(OUTPUT)util/bpf_lock_contention.o: $(SKEL_OUT)/lock_contention.skel.h +$(OUTPUT)util/bpf_kwork.o: $(SKEL_OUT)/kwork_trace.skel.h +endif -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 09/18] perf build: Encapsulate vmlinux.h and bpftool in bpf_skel.mak 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (7 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 08/18] perf build: Move BPF skeleton generation out of Makefile.perf Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 10/18] perf build: Move static libbpf dependency out of prepare step Ian Rogers ` (8 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song Currently, bpftool and vmlinux.h are prerequisites of the top-level prepare target in Makefile.perf. This unnecessarily blocks the massive parallel C compilation of libraries (perf-util, perf-ui, pmu-events) during the initial startup phase. Move all bpftool and vmlinux.h generation rules down into tools/perf/bpf_skel.mak to encapsulate BPF tooling completely within the skeleton framework. Remove them entirely from prepare to unblock immediate parallel build execution. To prevent parallel sub-makes (perf-util and perf-bench) from racing to build shared prerequisites concurrently, while maintaining strict directory encapsulation without top-level inclusions, serialize bench after the util static archive finishes using an order-only prerequisite: $(LIBPERF_BENCH_IN): FORCE prepare | $(LIBPERF_UTIL) Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.config | 2 +- tools/perf/Makefile.perf | 61 +++++--------------------------------- tools/perf/bpf_skel.mak | 47 +++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 06d7a3f9990c..bc1111c88226 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -736,7 +736,7 @@ ifeq ($(BUILD_BPF_SKEL),1) endif ifndef GEN_VMLINUX_H - VMLINUX_H=$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h + VMLINUX_H_FILE=$(src-perf)/util/bpf_skel/vmlinux/vmlinux.h endif dwarf-post-unwind := 1 diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index d4fc10f36781..ec0e91bedce1 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -274,7 +274,7 @@ ifeq ($(PYLINT),1) PYLINT := $(shell which pylint 2> /dev/null) endif -export srctree OUTPUT RM CC CXX RUSTC CLANG LD AR CFLAGS CXXFLAGS RUST_FLAGS V BISON FLEX AWK LIBBPF +export srctree OUTPUT RM CC CXX RUSTC CLANG LD AR CFLAGS CXXFLAGS RUST_FLAGS V BISON FLEX AWK LIBBPF READELF export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT include $(srctree)/tools/build/Makefile.include @@ -324,7 +324,7 @@ else FEATURE_DUMP_EXPORT := $(realpath $(FEATURES_DUMP)) endif -export prefix bindir sharedir sysconfdir DESTDIR +export prefix bindir sharedir sysconfdir DESTDIR VMLINUX_H_FILE # sparse is architecture-neutral, which means that we need to tell it # explicitly what architecture to check for. Fix this up for yours.. @@ -556,7 +556,9 @@ $(LIBPMU_EVENTS_IN): FORCE $(LIBPERF) $(LIBPMU_EVENTS): $(LIBPMU_EVENTS_IN) $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $< -$(LIBPERF_BENCH_IN): FORCE prepare +# The $(LIBPERF_UTIL) dependency is to ensure bpftool and vmlinux.h +# aren't racily built for bench/bpf_skel/bench_uprobe.bpf.c +$(LIBPERF_BENCH_IN): FORCE prepare | $(LIBPERF_UTIL) $(Q)$(MAKE) $(build)=perf-bench $(LIBPERF_BENCH): $(LIBPERF_BENCH_IN) @@ -911,60 +913,11 @@ $(INSTALL_DOC_TARGETS): python-clean: $(python-clean) -SKEL_OUT := $(abspath $(OUTPUT)util/bpf_skel) -SKEL_TMP_OUT := $(abspath $(SKEL_OUT)/.tmp) - -$(SKEL_TMP_OUT) $(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT): +$(LIBAPI_OUTPUT) $(LIBBPF_OUTPUT) $(LIBPERF_OUTPUT) $(LIBSUBCMD_OUTPUT) $(LIBSYMBOL_OUTPUT): $(Q)$(MKDIR) -p $@ -ifeq ($(CONFIG_PERF_BPF_SKEL),y) -prepare: $(BPFTOOL) $(SKEL_OUT)/vmlinux.h -BPFTOOL := $(SKEL_TMP_OUT)/bootstrap/bpftool - -$(BPFTOOL): | $(SKEL_TMP_OUT) - $(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool \ - OUTPUT=$(SKEL_TMP_OUT)/ bootstrap - -# Paths to search for a kernel to generate vmlinux.h from. -VMLINUX_BTF_ELF_PATHS ?= $(if $(O),$(O)/vmlinux) \ - $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \ - ../../vmlinux \ - /boot/vmlinux-$(shell uname -r) - -# Paths to BTF information. -VMLINUX_BTF_BTF_PATHS ?= /sys/kernel/btf/vmlinux - -# Filter out kernels that don't exist or without a BTF section. -VMLINUX_BTF_ELF_ABSPATHS ?= $(abspath $(wildcard $(VMLINUX_BTF_ELF_PATHS))) -VMLINUX_BTF_PATHS ?= $(shell for file in $(VMLINUX_BTF_ELF_ABSPATHS); \ - do \ - if [ -f $$file ] && ($(READELF) -S "$$file" | grep -q .BTF); \ - then \ - echo "$$file"; \ - fi; \ - done) \ - $(wildcard $(VMLINUX_BTF_BTF_PATHS)) - -# Select the first as the source of vmlinux.h. -VMLINUX_BTF ?= $(firstword $(VMLINUX_BTF_PATHS)) - -ifeq ($(VMLINUX_H),) - ifeq ($(VMLINUX_BTF),) - $(error Missing bpftool input for generating vmlinux.h) - endif -endif - -$(SKEL_OUT)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) $(VMLINUX_H) -ifeq ($(VMLINUX_H),) - $(QUIET_GEN)$(BPFTOOL) btf dump file $< format c > $@ -else - $(Q)cp "$(VMLINUX_H)" $@ -endif - -endif # CONFIG_PERF_BPF_SKEL - bpf-skel-clean: - $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKEL_OUT)/*.skel.h $(SKEL_OUT)/vmlinux.h $(OUTPUT)bench/bpf_skel/*.skel.h + $(Q)$(MAKE) -f bpf_skel.mak clean pmu-events-clean: ifeq ($(OUTPUT),) diff --git a/tools/perf/bpf_skel.mak b/tools/perf/bpf_skel.mak index bcb704d5af32..ded578b9570c 100644 --- a/tools/perf/bpf_skel.mak +++ b/tools/perf/bpf_skel.mak @@ -36,6 +36,47 @@ ifneq ($(WERROR),0) CLANG_OPTIONS += -Werror endif +$(BPFTOOL): + $(Q)mkdir -p $(SKEL_TOOL_TMP_OUT) + $(Q)CFLAGS= $(MAKE) -C ../bpf/bpftool OUTPUT=$(SKEL_TOOL_TMP_OUT)/ bootstrap + +# Paths to search for a kernel to generate vmlinux.h from. +VMLINUX_BTF_ELF_PATHS ?= $(if $(O),$(O)/vmlinux) \ + $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \ + ../../vmlinux \ + /boot/vmlinux-$(shell uname -r) + +# Paths to BTF information. +VMLINUX_BTF_BTF_PATHS ?= /sys/kernel/btf/vmlinux + +# Filter out kernels that don't exist or without a BTF section. +VMLINUX_BTF_ELF_ABSPATHS ?= $(abspath $(wildcard $(VMLINUX_BTF_ELF_PATHS))) +VMLINUX_BTF_PATHS ?= $(shell for file in $(VMLINUX_BTF_ELF_ABSPATHS); \ + do \ + if [ -f $$file ] && ($(READELF) -S "$$file" | grep -q .BTF); \ + then \ + echo "$$file"; \ + fi; \ + done) \ + $(wildcard $(VMLINUX_BTF_BTF_PATHS)) + +# Select the first as the source of vmlinux.h. +VMLINUX_BTF ?= $(firstword $(VMLINUX_BTF_PATHS)) + +ifeq ($(VMLINUX_H_FILE),) + ifeq ($(VMLINUX_BTF),) + $(error Missing bpftool input for generating vmlinux.h) + endif +endif + +$(VMLINUX_H): $(VMLINUX_BTF) $(BPFTOOL) $(VMLINUX_H_FILE) + $(call rule_mkdir) +ifeq ($(VMLINUX_H_FILE),) + $(QUIET_GEN)$(BPFTOOL) btf dump file $< format c > $@ +else + $(Q)cp "$(VMLINUX_H_FILE)" $@ +endif + # Consolidated Pattern rule for $(dir)/bpf_skel/ $(SKEL_TMP_OUT)/%.bpf.o: $(srctree)/tools/perf/$(dir)/bpf_skel/%.bpf.c $(LIBBPF) $(VMLINUX_H) $(OUTPUT)PERF-VERSION-FILE util/bpf_skel/perf_version.h $(call rule_mkdir) @@ -52,4 +93,10 @@ $(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o $(BPFTOOL) $(Q)$(BPFTOOL) gen skeleton $< > $@ .PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o + endif # CONFIG_PERF_BPF_SKEL + +clean: + $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TOOL_TMP_OUT) $(OUTPUT)bench/bpf_skel/.tmp $(SKEL_TOOL_OUT)/*.skel.h $(OUTPUT)bench/bpf_skel/*.skel.h $(SKEL_TOOL_OUT)/vmlinux.h + +.PHONY: clean -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 10/18] perf build: Move static libbpf dependency out of prepare step 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (8 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 09/18] perf build: Encapsulate vmlinux.h and bpftool in bpf_skel.mak Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 11/18] perf build: Pre-generate BPF skeleton tooling during umbrella prepare phase Ian Rogers ` (7 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song The prepare step is a large serialization point before parallel sub-makes build the perf tool. The libbpf headers are used in the bench and util libraries, as well as individual perf builtin commands. Move the libbpf dependency out of the prepare step and into the dependencies for those targets to avoid it being a source of serialization in the prepare step. Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index ec0e91bedce1..5af767415c11 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -547,7 +547,7 @@ export NO_JEVENTS build := -f $(srctree)/tools/build/Makefile.build dir=. obj -$(PERF_IN): prepare FORCE +$(PERF_IN): prepare $(LIBBPF) FORCE $(Q)$(MAKE) $(build)=perf $(LIBPMU_EVENTS_IN): FORCE $(LIBPERF) @@ -558,7 +558,7 @@ $(LIBPMU_EVENTS): $(LIBPMU_EVENTS_IN) # The $(LIBPERF_UTIL) dependency is to ensure bpftool and vmlinux.h # aren't racily built for bench/bpf_skel/bench_uprobe.bpf.c -$(LIBPERF_BENCH_IN): FORCE prepare | $(LIBPERF_UTIL) +$(LIBPERF_BENCH_IN): FORCE prepare $(LIBBPF) | $(LIBPERF_UTIL) $(Q)$(MAKE) $(build)=perf-bench $(LIBPERF_BENCH): $(LIBPERF_BENCH_IN) @@ -576,7 +576,7 @@ $(LIBPERF_UI_IN): FORCE prepare $(LIBPERF_UI): $(LIBPERF_UI_IN) $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $< -$(LIBPERF_UTIL_IN): FORCE prepare +$(LIBPERF_UTIL_IN): FORCE prepare $(LIBBPF) $(Q)$(MAKE) $(build)=perf-util $(LIBPERF_UTIL): $(LIBPERF_UTIL_IN) @@ -636,10 +636,6 @@ prepare: $(OUTPUT)PERF-VERSION-FILE \ $(LIBSUBCMD) \ $(LIBSYMBOL) -ifdef LIBBPF_STATIC -prepare: $(LIBBPF) -endif - $(OUTPUT)%.o: %.c prepare FORCE $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 11/18] perf build: Pre-generate BPF skeleton tooling during umbrella prepare phase 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (9 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 10/18] perf build: Move static libbpf dependency out of prepare step Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 12/18] perf build: Move libsymbol dependency out of prepare step Ian Rogers ` (6 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song Currently, BPF skeleton generation rules (bpf_skel.mak) are evaluated as part of util/Build. However, because LIBPERF_UTIL_IN explicitly depends on the top-level static libbpf archive, Make completely blocked the execution of bpftool bootstrap and skeleton generation until libbpf finished compiling midway through the build. Since bpftool bootstrap compiles its own independent copy of libbpf.a, it does not depend on the top-level libbpf target. Decouple early skeleton tooling generation by attaching bpf-skel-prepare to the umbrella prepare target, exporting CONFIG_PERF_BPF_SKEL to ensure accurate feature propagation. This allows Make to compile bpftool and dump vmlinux.h in the background at build startup, eliminating the initial sub-make startup bottleneck before BPF object compilation while keeping 100% of tooling rules perfectly encapsulated in bpf_skel.mak. Provide an empty fallback target to ensure builds succeed when BPF skeletons are disabled. Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 6 +++++- tools/perf/bpf_skel.mak | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 5af767415c11..df68d29ecab7 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -275,7 +275,7 @@ ifeq ($(PYLINT),1) endif export srctree OUTPUT RM CC CXX RUSTC CLANG LD AR CFLAGS CXXFLAGS RUST_FLAGS V BISON FLEX AWK LIBBPF READELF -export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT +export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT CONFIG_PERF_BPF_SKEL include $(srctree)/tools/build/Makefile.include @@ -629,8 +629,12 @@ endif __build-dir = $(subst $(OUTPUT),,$(dir $@)) build-dir = $(or $(__build-dir),.) +bpf-skel-prepare: + $(Q)$(MAKE) -f bpf_skel.mak bpf-skel-prepare + prepare: $(OUTPUT)PERF-VERSION-FILE \ arm64-sysreg-defs \ + bpf-skel-prepare \ $(LIBAPI) \ $(LIBPERF) \ $(LIBSUBCMD) \ diff --git a/tools/perf/bpf_skel.mak b/tools/perf/bpf_skel.mak index ded578b9570c..c4340a218323 100644 --- a/tools/perf/bpf_skel.mak +++ b/tools/perf/bpf_skel.mak @@ -16,6 +16,10 @@ BPFTOOL := $(SKEL_TOOL_TMP_OUT)/bootstrap/bpftool VMLINUX_H := $(SKEL_TOOL_OUT)/vmlinux.h bpf_skel_deps := $(BPFTOOL) $(VMLINUX_H) +.PHONY: bpf-skel-prepare +bpf-skel-prepare: $(bpf_skel_deps) + @: + define get_sys_includes $(shell $(1) $(2) -v -E - </dev/null 2>&1 \ | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ @@ -94,6 +98,10 @@ $(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o $(BPFTOOL) .PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o +else # CONFIG_PERF_BPF_SKEL +.PHONY: bpf-skel-prepare +bpf-skel-prepare: + @: endif # CONFIG_PERF_BPF_SKEL clean: -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 12/18] perf build: Move libsymbol dependency out of prepare step 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (10 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 11/18] perf build: Pre-generate BPF skeleton tooling during umbrella prepare phase Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 13/18] perf build: Remove redundant libbpf feature check for static builds Ian Rogers ` (5 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song The prepare step is a large serialization point before parallel sub-makes build the perf tool. The libsymbol headers are used in the bench and util libraries. Move the libsymbol dependency out of the prepare step and into the dependencies for those targets to avoid it being a source of serialization in the prepare step. Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index df68d29ecab7..d2e673d5e5be 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -558,7 +558,7 @@ $(LIBPMU_EVENTS): $(LIBPMU_EVENTS_IN) # The $(LIBPERF_UTIL) dependency is to ensure bpftool and vmlinux.h # aren't racily built for bench/bpf_skel/bench_uprobe.bpf.c -$(LIBPERF_BENCH_IN): FORCE prepare $(LIBBPF) | $(LIBPERF_UTIL) +$(LIBPERF_BENCH_IN): FORCE prepare $(LIBBPF) $(LIBSYMBOL) | $(LIBPERF_UTIL) $(Q)$(MAKE) $(build)=perf-bench $(LIBPERF_BENCH): $(LIBPERF_BENCH_IN) @@ -576,7 +576,7 @@ $(LIBPERF_UI_IN): FORCE prepare $(LIBPERF_UI): $(LIBPERF_UI_IN) $(QUIET_AR)$(RM) $@ && $(AR) rcs $@ $< -$(LIBPERF_UTIL_IN): FORCE prepare $(LIBBPF) +$(LIBPERF_UTIL_IN): FORCE prepare $(LIBBPF) $(LIBSYMBOL) $(Q)$(MAKE) $(build)=perf-util $(LIBPERF_UTIL): $(LIBPERF_UTIL_IN) @@ -637,8 +637,7 @@ prepare: $(OUTPUT)PERF-VERSION-FILE \ bpf-skel-prepare \ $(LIBAPI) \ $(LIBPERF) \ - $(LIBSUBCMD) \ - $(LIBSYMBOL) + $(LIBSUBCMD) $(OUTPUT)%.o: %.c prepare FORCE $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 13/18] perf build: Remove redundant libbpf feature check for static builds 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (11 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 12/18] perf build: Move libsymbol dependency out of prepare step Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 14/18] perf pmu-events: Split big_c_string storage into standalone compilation unit Ian Rogers ` (4 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song By default, the perf tool compiles and statically links against its own internal copy of libbpf (tools/lib/bpf/libbpf.a), setting LIBBPF_STATIC=1. Despite this static linkage, Makefile.config unconditionally executed $(call feature_check,libbpf), which forced a synchronous sub-make fork during AST parsing to detect dynamic system libbpf libraries. As noted in the internal Makefile comments, this check was executed purely so that running `make VF=1` would display the detection status of system libbpf. During standard builds without LIBBPF_DYNAMIC=1, the detection result was entirely ignored. Wrap the libbpf feature check inside LIBBPF_DYNAMIC=1 so Make avoids the redundant sub-make fork overhead during standard static builds. Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.config | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index bc1111c88226..fbe7fa83b0bb 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -587,10 +587,8 @@ ifndef NO_LIBELF ifndef NO_LIBBPF ifeq ($(feature-bpf), 1) - # detecting libbpf without LIBBPF_DYNAMIC, so make VF=1 shows libbpf detection status - $(call feature_check,libbpf) - ifdef LIBBPF_DYNAMIC + $(call feature_check,libbpf) ifeq ($(feature-libbpf), 1) EXTLIBS += -lbpf CFLAGS += -DHAVE_LIBBPF_SUPPORT -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 14/18] perf pmu-events: Split big_c_string storage into standalone compilation unit 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (12 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 13/18] perf build: Remove redundant libbpf feature check for static builds Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 15/18] perf pmu-events: Parallelize JSON and metric pre-computation in jevents.py Ian Rogers ` (3 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song Currently, jevents.py emits both the massive 2.8 MB big_c_string literal and tens of thousands of compact_pmu_event struct arrays into a single pmu-events.c compilation unit. Compiling this giant file takes ~2.2 seconds on a single CPU core during Kbuild startup. Refactor jevents.py to emit big_c_string into a dedicated pmu-events-string.c compilation unit. This allows Kbuild to compile pmu-events.o and pmu-events-string.o simultaneously in parallel across two separate CPU cores, preserving 100% string deduplication and zero dynamic ELF relocations while cutting C compilation latency in half. Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 4 ++-- tools/perf/pmu-events/Build | 15 +++++++++++++-- tools/perf/pmu-events/jevents.py | 20 ++++++++++++++++---- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index d2e673d5e5be..98b6f9fda8d1 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -921,7 +921,7 @@ bpf-skel-clean: pmu-events-clean: ifeq ($(OUTPUT),) $(call QUIET_CLEAN, pmu-events) $(RM) \ - pmu-events/pmu-events.c \ + pmu-events/pmu-events*.c \ pmu-events/metric_test.log \ pmu-events/test-empty-pmu-events.c \ pmu-events/empty-pmu-events.log @@ -929,7 +929,7 @@ ifeq ($(OUTPUT),) -name 'extra-metricgroups.json' -delete else # When an OUTPUT directory is present, clean up the copied pmu-events/arch directory. $(call QUIET_CLEAN, pmu-events) $(RM) -r $(OUTPUT)pmu-events/arch \ - $(OUTPUT)pmu-events/pmu-events.c \ + $(OUTPUT)pmu-events/pmu-events*.c \ $(OUTPUT)pmu-events/metric_test.log \ $(OUTPUT)pmu-events/test-empty-pmu-events.c \ $(OUTPUT)pmu-events/empty-pmu-events.log diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build index dc1df2d57ddc..e957aa2fcb48 100644 --- a/tools/perf/pmu-events/Build +++ b/tools/perf/pmu-events/Build @@ -1,7 +1,12 @@ EMPTY_PMU_EVENTS_C = pmu-events/empty-pmu-events.c # pmu-events.c will be generated by jevents.py or copied from EMPTY_PMU_EVENTS_C PMU_EVENTS_C = $(OUTPUT)pmu-events/pmu-events.c +PMU_EVENTS_STRING_C = $(OUTPUT)pmu-events/pmu-events-string.c + pmu-events-y += pmu-events.o +ifneq ($(NO_JEVENTS),1) +pmu-events-y += pmu-events-string.o +endif # pmu-events.c file is generated in the OUTPUT directory so it needs a # separate rule to depend on it properly @@ -9,6 +14,10 @@ $(OUTPUT)pmu-events/pmu-events.o: $(PMU_EVENTS_C) $(call rule_mkdir) $(call if_changed_dep,cc_o_c) +$(OUTPUT)pmu-events/pmu-events-string.o: $(PMU_EVENTS_STRING_C) + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c) + # Message for $(call echo-cmd,cp), possibly remove the src file from # the destination to save space in the build log. quiet_cmd_cp = COPY $(patsubst %$<,%,$@) <- $< @@ -118,6 +127,7 @@ CUR_OUT_JSON := $(shell [ -d $(OUT_DIR) ] && find $(OUT_DIR) -type f) # Things in the OUTPUT directory but shouldn't be there as computed by # OUT_JSON and GEN_JSON. + ORPHAN_FILES := $(filter-out $(OUT_JSON) $(GEN_JSON),$(CUR_OUT_JSON)) # Message for $(call echo-cmd,mkd). There is already a mkdir message @@ -222,8 +232,9 @@ endif # Finally, the rule to build pmu-events.c using jevents.py. All test # and inputs are dependencies. -$(PMU_EVENTS_C): $(JEVENTS_DEPS) +$(PMU_EVENTS_STRING_C) $(PMU_EVENTS_C) &: $(JEVENTS_DEPS) $(call rule_mkdir) - $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) $(OUT_DIR) $@ + $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS_MODEL) \ + $(OUT_DIR) $(PMU_EVENTS_C) $(PMU_EVENTS_STRING_C) endif # ifeq ($(NO_JEVENTS),1) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 3a1bcdcdc685..70a45e62f5d1 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -1422,6 +1422,8 @@ such as "arm/cortex-a34".''', ) ap.add_argument( 'output_file', type=argparse.FileType('w', encoding='utf-8'), nargs='?', default=sys.stdout) + ap.add_argument( + 'output_string_file', type=argparse.FileType('w', encoding='utf-8'), nargs='?', default=None) _args = ap.parse_args() _args.output_file.write(f""" @@ -1463,10 +1465,20 @@ struct pmu_table_entry { ftw(arch_path, [], preprocess_one_file) _bcs.compute() - _args.output_file.write('static const char *const big_c_string =\n') - for s in _bcs.big_string: - _args.output_file.write(s) - _args.output_file.write(';\n\n') + if not _args.output_string_file: + _args.output_file.write('static const char *const big_c_string =\n') + for s in _bcs.big_string: + _args.output_file.write(s) + _args.output_file.write(';\n\n') + else: + _args.output_string_file.write('/* SPDX-License-Identifier: GPL-2.0 */\n') + _args.output_string_file.write('/* Autogenerated by jevents.py */\n') + _args.output_string_file.write('const char big_c_string[] =\n') + for s in _bcs.big_string: + _args.output_string_file.write(s) + _args.output_string_file.write(';\n') + _args.output_string_file.close() + _args.output_file.write('extern const char big_c_string[];\n\n') for arch in archs: arch_path = f'{_args.starting_dir}/{arch}' ftw(arch_path, [], process_one_file) -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 15/18] perf pmu-events: Parallelize JSON and metric pre-computation in jevents.py 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (13 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 14/18] perf pmu-events: Split big_c_string storage into standalone compilation unit Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 16/18] perf build: Prefix SCRIPTS with output directory to fix continuous rebuilds Ian Rogers ` (2 subsequent siblings) 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song Currently, jevents.py parses hundreds of JSON event and metric files sequentially across all CPU architectures during Kbuild startup, taking ~3.3 seconds of pure single-core execution time. Refactor jevents.py to pre-populate its internal JSON AST cache in parallel across all available CPU cores using ProcessPoolExecutor. Configure worker process initializers to guarantee standard event mapping inheritance under spawn multiprocessing semantics, and apply depth filtering to prevent redundant worker tasks. This accelerates jevents.py execution by over 11x (from 3.3s down to ~290ms), fully reclaiming multi-core concurrency during the build generation phase. Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/pmu-events/jevents.py | 36 ++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 70a45e62f5d1..eb72c154f946 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -457,8 +457,8 @@ class JsonEvent: return f'{{ { _bcs.offsets[s] } }}, /* {fix_comment(s)} */\n' -@lru_cache(maxsize=None) -def read_json_events(path: str, topic: str) -> Sequence[JsonEvent]: +_json_cache = {} +def _read_json_events_impl(path: str, topic: str) -> Sequence[JsonEvent]: """Read json events from the specified file.""" try: events = json.load(open(path), object_hook=JsonEvent) @@ -474,12 +474,16 @@ def read_json_events(path: str, topic: str) -> Sequence[JsonEvent]: if updates: for event in events: if event.metric_name in updates: - # print(f'Updated {event.metric_name} from\n"{event.metric_expr}"\n' - # f'to\n"{updates[event.metric_name]}"') event.metric_expr = updates[event.metric_name] return events +def read_json_events(path: str, topic: str) -> Sequence[JsonEvent]: + key = (path, topic) + if key not in _json_cache: + _json_cache[key] = _read_json_events_impl(path, topic) + return _json_cache[key] + def preprocess_arch_std_files(archpath: str) -> None: """Read in all architecture standard events.""" global _arch_std_events @@ -1381,6 +1385,10 @@ const char *describe_metricgroup(const char *group) } """) +def _parallel_read_json_events(task: Tuple[str, str]) -> Tuple[str, str, Sequence[JsonEvent]]: + path, topic = task + return path, topic, _read_json_events_impl(path, topic) + def main() -> None: global _args @@ -1459,9 +1467,29 @@ struct pmu_table_entry { raise IOError(f'Missing architecture directory \'{_args.arch}\'') archs.sort() + import concurrent.futures + tasks = [] + def collect_json(parents: Sequence[str], item: os.DirEntry) -> None: + if len(parents) == 0: + return + if item.is_file() and item.name.endswith('.json') and not item.name.endswith('metricgroups.json'): + tasks.append((item.path, get_topic(item.name))) + for arch in archs: arch_path = f'{_args.starting_dir}/{arch}' preprocess_arch_std_files(arch_path) + ftw(arch_path, [], collect_json) + + def _init_worker(std_events: dict) -> None: + global _arch_std_events + _arch_std_events = std_events + + with concurrent.futures.ProcessPoolExecutor(initializer=_init_worker, initargs=(_arch_std_events,)) as executor: + for path, topic, events in executor.map(_parallel_read_json_events, tasks): + _json_cache[(path, topic)] = events + + for arch in archs: + arch_path = f'{_args.starting_dir}/{arch}' ftw(arch_path, [], preprocess_one_file) _bcs.compute() -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 16/18] perf build: Prefix SCRIPTS with output directory to fix continuous rebuilds 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (14 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 15/18] perf pmu-events: Parallelize JSON and metric pre-computation in jevents.py Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 17/18] perf pmu-events: Convert recursive shell assignments and macros to Make built-ins Ian Rogers 2026-05-12 17:46 ` [PATCH v2 18/18] perf build: Convert llvm-config shell queries to simply expanded variables Ian Rogers 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song In Makefile.perf, ALL_PROGRAMS includes SCRIPTS (perf-archive, perf-iostat). However, unlike PROGRAMS and DLFILTERS, SCRIPTS was not prefixed with $(OUTPUT). During out-of-tree builds (or when O= is specified), Make checked for the unprefixed target 'tools/perf/perf-archive'. Since the actual script was installed into $(OUTPUT)perf-archive, Make concluded the target was missing and continuously re-executed the script installation rule on every single incremental build. Prefix SCRIPTS with $(OUTPUT) and update the static pattern rule to ensure Kbuild correctly tracks generated script prerequisites during incremental builds. Tested-by: James Clark <james.clark@linaro.org> Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.perf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 98b6f9fda8d1..e700cc1ed028 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -405,7 +405,7 @@ python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT # Use the detected configuration -include $(OUTPUT).config-detected -SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) +SCRIPTS = $(addprefix $(OUTPUT),$(patsubst %.sh,%,$(SCRIPT_SH))) PROGRAMS += $(OUTPUT)perf @@ -592,8 +592,8 @@ $(GTK_IN): FORCE prepare $(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS) $(QUIET_LINK)$(CC) -o $@ -shared $(LDFLAGS) $(filter %.o,$^) $(GTK_LIBS) -$(SCRIPTS) : % : %.sh - $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@' +$(SCRIPTS) : $(OUTPUT)% : %.sh + $(QUIET_GEN)$(INSTALL) '$<' '$@' $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE $(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 17/18] perf pmu-events: Convert recursive shell assignments and macros to Make built-ins 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (15 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 16/18] perf build: Prefix SCRIPTS with output directory to fix continuous rebuilds Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 2026-05-12 17:46 ` [PATCH v2 18/18] perf build: Convert llvm-config shell queries to simply expanded variables Ian Rogers 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song In pmu-events/Build, ZENS, ARMS, and INTELS were assigned using recursive assignment (=), and model_name/vendor_name were evaluated using shell macros (echo ... | sed ...). Because these variables were expanded inside the COPY_RULE dependency evaluation loop across hundreds of PMU JSON files and inside every metric generation recipe, Kbuild continuously re-executed 'ls', 'grep', and 'sed' shell forks thousands of times during AST parsing and execution. Convert ZENS, ARMS, and INTELS to simply expanded variables (:=) and replace model_name/vendor_name with pure GNU Make string functions. This guarantees Make executes directory probing shell forks exactly once when the Build file is parsed and evaluates path macros purely in memory, completely eliminating over 7,800 redundant sub-processes during build startup. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/pmu-events/Build | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build index e957aa2fcb48..246b04f73ccf 100644 --- a/tools/perf/pmu-events/Build +++ b/tools/perf/pmu-events/Build @@ -56,12 +56,12 @@ $(LEGACY_CACHE_JSON): $(LEGACY_CACHE_PY) # Python to generate architectural metrics GEN_METRIC_DEPS := pmu-events/metric.py pmu-events/common_metrics.py # Functions to extract the model from an extra-metrics.json or extra-metricgroups.json path. -model_name = $(shell echo $(1)|sed -e 's@.\+/\(.*\)/extra-metric.*\.json@\1@') -vendor_name = $(shell echo $(1)|sed -e 's@.\+/\(.*\)/[^/]*/extra-metric.*\.json@\1@') +model_name = $(notdir $(patsubst %/,%,$(dir $(1)))) +vendor_name = $(notdir $(patsubst %/,%,$(dir $(patsubst %/,%,$(dir $(1)))))) ifeq ($(JEVENTS_ARCH),$(filter $(JEVENTS_ARCH),x86 all)) # Generate AMD Json -ZENS = $(shell ls -d pmu-events/arch/x86/amdzen*) +ZENS := $(shell ls -d pmu-events/arch/x86/amdzen*) ZEN_METRICS = $(foreach x,$(ZENS),$(OUTPUT)$(x)/extra-metrics.json) ZEN_METRICGROUPS = $(foreach x,$(ZENS),$(OUTPUT)$(x)/extra-metricgroups.json) GEN_JSON += $(ZEN_METRICS) $(ZEN_METRICGROUPS) @@ -78,7 +78,7 @@ endif ifeq ($(JEVENTS_ARCH),$(filter $(JEVENTS_ARCH),arm64 all)) # Generate ARM Json -ARMS = $(shell ls -d pmu-events/arch/arm64/arm/*|grep -v cmn) +ARMS := $(shell ls -d pmu-events/arch/arm64/arm/*|grep -v cmn) ARM_METRICS = $(foreach x,$(ARMS),$(OUTPUT)$(x)/extra-metrics.json) ARM_METRICGROUPS = $(foreach x,$(ARMS),$(OUTPUT)$(x)/extra-metricgroups.json) GEN_JSON += $(ARM_METRICS) $(ARM_METRICGROUPS) @@ -95,7 +95,7 @@ endif ifeq ($(JEVENTS_ARCH),$(filter $(JEVENTS_ARCH),x86 all)) # Generate Intel Json -INTELS = $(shell ls -d pmu-events/arch/x86/*|grep -v amdzen|grep -v mapfile.csv) +INTELS := $(shell ls -d pmu-events/arch/x86/*|grep -v amdzen|grep -v mapfile.csv) INTEL_METRICS = $(foreach x,$(INTELS),$(OUTPUT)$(x)/extra-metrics.json) INTEL_METRICGROUPS = $(foreach x,$(INTELS),$(OUTPUT)$(x)/extra-metricgroups.json) GEN_JSON += $(INTEL_METRICS) $(INTEL_METRICGROUPS) -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* [PATCH v2 18/18] perf build: Convert llvm-config shell queries to simply expanded variables 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers ` (16 preceding siblings ...) 2026-05-12 17:46 ` [PATCH v2 17/18] perf pmu-events: Convert recursive shell assignments and macros to Make built-ins Ian Rogers @ 2026-05-12 17:46 ` Ian Rogers 17 siblings, 0 replies; 36+ messages in thread From: Ian Rogers @ 2026-05-12 17:46 UTC (permalink / raw) To: irogers, acme, james.clark, namhyung Cc: 9erthalion6, adrian.hunter, alex, alexandre.chartre, andrii, ankur.a.arora, aou, bpf, collin.funk1, costa.shul, daniel, dapeng1.mi, dsterba, eddyz87, howardchu95, jolsa, leo.yan, linux-kernel, linux-perf-users, martin.lau, memxor, mingo, mmayer, nathan, palmer, peterz, pjw, qmo, ricky.ringler, song, swapnil.sapkal, terrelln, tglozar, thomas.falcon, yonghong.song In Makefile.config, CFLAGS, CXXFLAGS, LIBLLVM, and EXTLIBS were assigned using recursive expansion or appended with raw $(shell $(LLVM_CONFIG) ...) calls. Because these variables were expanded during dependency evaluation across every single object file compilation rule, Kbuild continuously re-executed llvm-config forks nearly 200 times during incremental builds. Convert llvm-config shell queries to simply expanded variables (:=) to ensure Make evaluates LLVM compiler flags and library paths exactly once when Makefile.config is parsed, eliminating ~185 redundant sub-processes during build startup. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> --- tools/perf/Makefile.config | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index fbe7fa83b0bb..7a61da082c0b 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -951,11 +951,14 @@ ifndef NO_LIBLLVM $(call feature_check,llvm-perf) ifeq ($(feature-llvm-perf), 1) CFLAGS += -DHAVE_LIBLLVM_SUPPORT - CFLAGS += $(shell $(LLVM_CONFIG) --cflags) - CXXFLAGS += -DHAVE_LIBLLVM_SUPPORT - CXXFLAGS += $(shell $(LLVM_CONFIG) --cxxflags) - LIBLLVM = $(shell $(LLVM_CONFIG) --libs all) $(shell $(LLVM_CONFIG) --system-libs) - EXTLIBS += -L$(shell $(LLVM_CONFIG) --libdir) $(LIBLLVM) + LLVM_CFLAGS := $(shell $(LLVM_CONFIG) --cflags 2>/dev/null) + LLVM_CXXFLAGS := $(shell $(LLVM_CONFIG) --cxxflags 2>/dev/null) + LLVM_LIBLLVM := $(shell $(LLVM_CONFIG) --libs all 2>/dev/null) $(shell $(LLVM_CONFIG) --system-libs 2>/dev/null) + LLVM_LIBDIR := $(shell $(LLVM_CONFIG) --libdir 2>/dev/null) + CFLAGS += $(LLVM_CFLAGS) + CXXFLAGS += -DHAVE_LIBLLVM_SUPPORT $(LLVM_CXXFLAGS) + LIBLLVM := $(LLVM_LIBLLVM) + EXTLIBS += -L$(LLVM_LIBDIR) $(LIBLLVM) EXTLIBS += -lstdc++ $(call detected,CONFIG_LIBLLVM) else -- 2.54.0.563.g4f69b47b94-goog ^ permalink raw reply related [flat|nested] 36+ messages in thread
* Re: [PATCH v1 00/14] perf build: Reduce build time by one third 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers ` (13 preceding siblings ...) 2026-05-12 5:35 ` [PATCH v1 14/14] perf build: Prefix SCRIPTS with output directory to fix continuous rebuilds Ian Rogers @ 2026-05-12 9:36 ` James Clark 14 siblings, 0 replies; 36+ messages in thread From: James Clark @ 2026-05-12 9:36 UTC (permalink / raw) To: Ian Rogers Cc: Quentin Monnet, Daniel Borkmann, Andrii Nakryiko, Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi, Song Liu, Yonghong Song, Jiri Olsa, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo, Namhyung Kim, Adrian Hunter, Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Nick Terrell, David Sterba, Nathan Chancellor, Tomas Glozar, Dmitrii Dolgov, Costa Shulyupin, Alexandre Chartre, Yuzhuo Jing, Leo Yan, Ankur Arora, Markus Mayer, Collin Funk, Howard Chu, Dapeng Mi, Swapnil Sapkal, Thomas Falcon, Ricky Ringler, linux-kernel, bpf, linux-perf-users On 12/05/2026 6:35 am, Ian Rogers wrote: > This patch series refactors many aspects of the perf build aiming to > better encapsulate BPF code generation, remove serial build code and > gain build parallelism. The prepare step that blocks the parallel > build is reduced to a core 6 smaller dependencies. BPF skeletons are > made regular dependencies on the targets that use them. Feature tests > and dependencies are reorgnized. The jevents.py script processes json > files in parallel and allows the big_c_string to be compiled > separately. > > On a 28-core build workstation (make -j28 all from scratch), clean build > latency improves by over 36%: > > Before: > real 0m29.006s > user 2m46.019s > sys 0m30.610s > > After: > real 0m18.498s > user 2m32.922s > sys 0m27.623s > I also get similar numbers, even when using ccache: Before: real 0m29.584s user 0m48.993s sys 0m20.466s After: real 0m18.322s user 0m49.995s sys 0m17.077s Tested-by: James Clark <james.clark@linaro.org> > Summary of Patches: > > 1: bpftool Bootstrap Optimization > - Exempts bpftool bootstrap from non-essential feature tests (LLVM, libbfd, > libcap), saving 1.1s of sub-make fork overhead during Kbuild startup. > > 2-4: Flattening Umbrella Prepare Barriers > - builtin-trace embedded inclusions and pmu-events generation are completely > decoupled from the sequential "prepare" umbrella target, eliminating Make > AST double-parsing overhead and unchoking parallel compilation barriers. > > 5-8: Decoupling & Pre-generating BPF Skeletons > - BPF skeleton rules are extracted out of Makefile.perf into bpf_skel.mak. > - Decouples bpftool bootstrap from top-level static libbpf dependencies, > attaching bpf-skel-prepare directly to the umbrella prepare target. This > allows Make to pre-compile bpftool and dump vmlinux.h in the background at > build startup, removing the 7-second serialization bottleneck before BPF > object compilation. > > 9-11: Foundational Linkage & Fast-Path Feature Detection > - Eliminates redundant libbpf sub-make feature checks during static builds. > - Integrates libdebuginfod directly into test-all.c, allowing Make to skip > individual feature check sub-make forks during AST parsing on fully > configured workstations. > > 12-13: jevents.py Concurrency & Deduplication > - Splits the massive 2.8 MB big_c_string literal out of pmu-events.c into a > dedicated pmu-events-string.c compilation unit. This slices C compilation > latency in half by compiling string and struct tables simultaneously across > separate CPU cores while preserving zero dynamic ELF relocations. > - Pre-populates jevents.py JSON ASTs and metric formulas in parallel across > all available CPU cores using ProcessPoolExecutor (accelerating Python > execution by 11x, from 3.3s down to ~290ms). > > 14: Out-of-Tree Incremental Rebuild Fix > - Prefixes SCRIPTS (perf-archive, perf-iostat) with $(OUTPUT) to prevent > Make from continuously re-executing script installation rules on already > built out-of-tree builds. > > Ian Rogers (14): > bpftool build: Restrict feature tests during bootstrap compilation > perf trace beauty: Make beauty generated C code standalone .o files > perf build: Decouple pmu-events from prepare umbrella target > perf build: Remove empty archheaders target > perf build: Move BPF skeleton generation out of Makefile.perf > perf build: Encapsulate vmlinux.h and bpftool in bpf_skel.mak > perf build: Move static libbpf dependency out of prepare step > perf build: Pre-generate BPF skeletons during umbrella prepare phase > perf build: Move libsymbol dependency out of prepare step > perf build: Remove redundant libbpf feature check for static builds > tools build: Integrate libdebuginfod into test-all fast path > perf pmu-events: Split big_c_string storage into standalone > compilation unit > perf pmu-events: Parallelize JSON and metric pre-computation in > jevents.py > perf build: Prefix SCRIPTS with output directory to fix continuous > rebuilds > > tools/bpf/bpftool/Makefile | 5 + > tools/build/Makefile.feature | 6 +- > tools/build/feature/Makefile | 2 +- > tools/build/feature/test-all.c | 5 + > tools/perf/Build | 2 + > tools/perf/Makefile.config | 6 +- > tools/perf/Makefile.perf | 427 +----------------- > tools/perf/bench/Build | 6 + > .../bpf_skel/bench_uprobe.bpf.c | 0 > tools/perf/bench/uprobe.c | 2 +- > tools/perf/bpf_skel.mak | 110 +++++ > tools/perf/builtin-trace.c | 30 +- > tools/perf/pmu-events/Build | 15 +- > tools/perf/pmu-events/jevents.py | 56 ++- > tools/perf/trace/beauty/Build | 280 ++++++++++++ > tools/perf/trace/beauty/arch_errno_names.c | 2 + > tools/perf/trace/beauty/arch_errno_names.sh | 2 +- > tools/perf/trace/beauty/beauty.h | 60 +++ > tools/perf/trace/beauty/eventfd.c | 6 +- > tools/perf/trace/beauty/fsconfig.c | 5 + > tools/perf/trace/beauty/futex_op.c | 6 +- > tools/perf/trace/beauty/futex_val3.c | 6 +- > tools/perf/trace/beauty/mmap.c | 24 +- > tools/perf/trace/beauty/mode_t.c | 6 +- > tools/perf/trace/beauty/msg_flags.c | 8 +- > tools/perf/trace/beauty/open_flags.c | 1 + > tools/perf/trace/beauty/perf_event_open.c | 22 +- > tools/perf/trace/beauty/pid.c | 5 +- > tools/perf/trace/beauty/sched_policy.c | 8 +- > tools/perf/trace/beauty/seccomp.c | 12 +- > tools/perf/trace/beauty/signum.c | 6 +- > tools/perf/trace/beauty/socket_type.c | 6 +- > .../perf/{util => trace/beauty}/syscalltbl.c | 0 > .../perf/{util => trace/beauty}/syscalltbl.h | 0 > tools/perf/trace/beauty/tracepoints/Build | 22 + > tools/perf/trace/beauty/waitid_options.c | 8 +- > tools/perf/util/Build | 17 +- > tools/perf/util/bpf-trace-summary.c | 2 +- > tools/perf/util/env.c | 4 +- > tools/perf/util/env.h | 1 + > 40 files changed, 700 insertions(+), 491 deletions(-) > rename tools/perf/{util => bench}/bpf_skel/bench_uprobe.bpf.c (100%) > create mode 100644 tools/perf/bpf_skel.mak > create mode 100644 tools/perf/trace/beauty/fsconfig.c > rename tools/perf/{util => trace/beauty}/syscalltbl.c (100%) > rename tools/perf/{util => trace/beauty}/syscalltbl.h (100%) > ^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2026-05-13 5:21 UTC | newest] Thread overview: 36+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-05-12 5:35 [PATCH v1 00/14] perf build: Reduce build time by one third Ian Rogers 2026-05-12 5:35 ` [PATCH v1 01/14] bpftool build: Restrict feature tests during bootstrap compilation Ian Rogers 2026-05-12 5:35 ` [PATCH v1 02/14] perf trace beauty: Make beauty generated C code standalone .o files Ian Rogers 2026-05-13 5:21 ` sashiko-bot 2026-05-12 5:35 ` [PATCH v1 03/14] perf build: Decouple pmu-events from prepare umbrella target Ian Rogers 2026-05-12 5:35 ` [PATCH v1 04/14] perf build: Remove empty archheaders target Ian Rogers 2026-05-12 5:35 ` [PATCH v1 05/14] perf build: Move BPF skeleton generation out of Makefile.perf Ian Rogers 2026-05-12 5:35 ` [PATCH v1 06/14] perf build: Encapsulate vmlinux.h and bpftool in bpf_skel.mak Ian Rogers 2026-05-12 5:35 ` [PATCH v1 07/14] perf build: Move static libbpf dependency out of prepare step Ian Rogers 2026-05-12 5:35 ` [PATCH v1 08/14] perf build: Pre-generate BPF skeletons during umbrella prepare phase Ian Rogers 2026-05-12 5:35 ` [PATCH v1 09/14] perf build: Move libsymbol dependency out of prepare step Ian Rogers 2026-05-12 5:35 ` [PATCH v1 10/14] perf build: Remove redundant libbpf feature check for static builds Ian Rogers 2026-05-12 5:35 ` [PATCH v1 11/14] tools build: Integrate libdebuginfod into test-all fast path Ian Rogers 2026-05-12 5:35 ` [PATCH v1 12/14] perf pmu-events: Split big_c_string storage into standalone compilation unit Ian Rogers 2026-05-12 5:35 ` [PATCH v1 13/14] perf pmu-events: Parallelize JSON and metric pre-computation in jevents.py Ian Rogers 2026-05-12 5:35 ` [PATCH v1 14/14] perf build: Prefix SCRIPTS with output directory to fix continuous rebuilds Ian Rogers 2026-05-12 17:46 ` [PATCH v2 00/18] perf build: Reduce build time by nearly half Ian Rogers 2026-05-12 17:46 ` [PATCH v2 01/18] bpftool build: Restrict feature tests during bootstrap compilation Ian Rogers 2026-05-12 17:46 ` [PATCH v2 02/18] tools build: Integrate libdebuginfod into test-all fast path Ian Rogers 2026-05-12 17:46 ` [PATCH v2 03/18] tools build: Fix test-clang-bpf-co-re.bin to generate target file Ian Rogers 2026-05-12 17:46 ` [PATCH v2 04/18] tools scripts: Short-circuit CC_NO_CLANG compiler probe in Makefile.include Ian Rogers 2026-05-12 17:46 ` [PATCH v2 05/18] perf trace beauty: Make beauty generated C code standalone .o files Ian Rogers 2026-05-12 17:46 ` [PATCH v2 06/18] perf build: Decouple pmu-events from prepare umbrella target Ian Rogers 2026-05-12 17:46 ` [PATCH v2 07/18] perf build: Remove empty archheaders target Ian Rogers 2026-05-12 17:46 ` [PATCH v2 08/18] perf build: Move BPF skeleton generation out of Makefile.perf Ian Rogers 2026-05-12 17:46 ` [PATCH v2 09/18] perf build: Encapsulate vmlinux.h and bpftool in bpf_skel.mak Ian Rogers 2026-05-12 17:46 ` [PATCH v2 10/18] perf build: Move static libbpf dependency out of prepare step Ian Rogers 2026-05-12 17:46 ` [PATCH v2 11/18] perf build: Pre-generate BPF skeleton tooling during umbrella prepare phase Ian Rogers 2026-05-12 17:46 ` [PATCH v2 12/18] perf build: Move libsymbol dependency out of prepare step Ian Rogers 2026-05-12 17:46 ` [PATCH v2 13/18] perf build: Remove redundant libbpf feature check for static builds Ian Rogers 2026-05-12 17:46 ` [PATCH v2 14/18] perf pmu-events: Split big_c_string storage into standalone compilation unit Ian Rogers 2026-05-12 17:46 ` [PATCH v2 15/18] perf pmu-events: Parallelize JSON and metric pre-computation in jevents.py Ian Rogers 2026-05-12 17:46 ` [PATCH v2 16/18] perf build: Prefix SCRIPTS with output directory to fix continuous rebuilds Ian Rogers 2026-05-12 17:46 ` [PATCH v2 17/18] perf pmu-events: Convert recursive shell assignments and macros to Make built-ins Ian Rogers 2026-05-12 17:46 ` [PATCH v2 18/18] perf build: Convert llvm-config shell queries to simply expanded variables Ian Rogers 2026-05-12 9:36 ` [PATCH v1 00/14] perf build: Reduce build time by one third James Clark
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox