tools/build/feature/Makefile | 13 +-
tools/perf/.gitignore | 1 +
tools/perf/Build | 2 +
tools/perf/Makefile.config | 19 +-
tools/perf/Makefile.perf | 423 ++----------------
tools/perf/bench/Build | 6 +
.../bpf_skel/bench_uprobe.bpf.c | 0
tools/perf/bench/uprobe.c | 2 +-
tools/perf/bpf_skel.mak | 109 +++++
tools/perf/builtin-trace.c | 32 +-
tools/perf/pmu-events/Build | 26 +-
tools/perf/pmu-events/jevents.py | 59 ++-
tools/perf/trace/beauty/Build | 276 ++++++++++++
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 | 5 +-
tools/perf/trace/beauty/futex_val3.c | 5 +-
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 | 2 +
tools/perf/trace/beauty/perf_event_open.c | 21 +-
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 | 21 +
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 +
38 files changed, 688 insertions(+), 516 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%)
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 44%:
Before:
real 0m29.006s
user 2m46.019s
sys 0m30.610s
After:
real 0m16.091s
user 2m40.135s
sys 0m25.740s
Saving 12.9 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.717s
user 0m1.682s
sys 0m0.960s
Summary of Patches:
1: Fast-Path Feature Detection
- Refactors test-clang-bpf-co-re.bin and test-bpftool-skeletons.bin feature
checks to group shell pipelines within curly braces and redirect both stdout
and stderr to .make.output before touching $@ purely upon success
(> $(@:.bin=.make.output) 2>&1 && touch $@). Grouping the pipeline ({ cmd1 | cmd2; })
ensures that compiler stderr is successfully captured in .make.output rather
than escaping to the parent shell. This perfectly matches standard Kbuild
feature check conventions and ensures the target files are touched on disk
purely upon success, allowing Kbuild to cache positive detections and avoid
continuous sub-make re-evaluations during incremental builds. Adds
test-bpftool-skeletons.bin to the clean FILES list and explicit source
prerequisite test-clang-bpf-co-re.c.
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-7: 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.
- Ensures benchmark skeleton intermediate .bpf.o files are cleanly removed
during make clean, and adds bpf-skel-prepare to .PHONY.
8-9: Foundational Linkage Optimization
- Moves static libsymbol library prerequisites out of the prepare step.
- Eliminates redundant libbpf sub-make feature checks during static builds.
10-11: 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. Adds
pmu-events-string.c to .gitignore, declares extern const char big_c_string[];
locally inside output_string_file and output_file when split to prevent linkage
conflicts with empty-pmu-events.c, defers file closures to ensure identical
timestamps, and uses canonical Make 4.0 @: dependency chaining.
- 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). Moves _init_worker to top-level
scope to ensure clean pickling under spawn multiprocessing start methods.
12: 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.
13-14: 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 v5:
- perf pmu-events (Patch 10): Refactored jevents.py to explicitly close output_file
first and output_string_file second at the absolute tail of main(), guaranteeing
that pmu-events-string.c receives a filesystem modification timestamp strictly
greater than or equal to pmu-events.c. This completely eliminates any nanosecond
timestamp discrepancy during Python teardown, ensuring Make's canonical @:
dependency chaining rule correctly sees pmu-events-string.c as fully up to
date and preventing redundant recompilations during incremental builds without
requiring manual touch commands in the Makefile.
Ian Rogers (14):
tools build: Fix feature checks to touch target files on success
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: 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/build/feature/Makefile | 13 +-
tools/perf/.gitignore | 1 +
tools/perf/Build | 2 +
tools/perf/Makefile.config | 19 +-
tools/perf/Makefile.perf | 423 ++----------------
tools/perf/bench/Build | 6 +
.../bpf_skel/bench_uprobe.bpf.c | 0
tools/perf/bench/uprobe.c | 2 +-
tools/perf/bpf_skel.mak | 109 +++++
tools/perf/builtin-trace.c | 32 +-
tools/perf/pmu-events/Build | 26 +-
tools/perf/pmu-events/jevents.py | 59 ++-
tools/perf/trace/beauty/Build | 276 ++++++++++++
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 | 5 +-
tools/perf/trace/beauty/futex_val3.c | 5 +-
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 | 2 +
tools/perf/trace/beauty/perf_event_open.c | 21 +-
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 | 21 +
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 +
38 files changed, 688 insertions(+), 516 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
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 44%:
Before:
real 0m29.006s
user 2m46.019s
sys 0m30.610s
After:
real 0m16.091s
user 2m40.135s
sys 0m25.740s
Saving 12.9 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.717s
user 0m1.682s
sys 0m0.960s
Summary of Patches:
1: Fast-Path Feature Detection
- Refactors test-clang-bpf-co-re.bin and test-bpftool-skeletons.bin feature
checks to group shell pipelines within curly braces and redirect both stdout
and stderr to .make.output before touching $@ purely upon success
(> $(@:.bin=.make.output) 2>&1 && touch $@). Grouping the pipeline ({ cmd1 | cmd2; })
ensures that compiler stderr is successfully captured in .make.output rather
than escaping to the parent shell. This perfectly matches standard Kbuild
feature check conventions and ensures the target files are touched on disk
purely upon success, allowing Kbuild to cache positive detections and avoid
continuous sub-make re-evaluations during incremental builds. Adds
test-bpftool-skeletons.bin to the clean FILES list and explicit source
prerequisite test-clang-bpf-co-re.c.
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-7: 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.
- Ensures benchmark skeleton intermediate .bpf.o files are cleanly removed
during make clean, and adds bpf-skel-prepare to .PHONY.
8-9: Foundational Linkage Optimization
- Moves static libsymbol library prerequisites out of the prepare step.
- Eliminates redundant libbpf sub-make feature checks during static builds.
10-11: 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. Adds
pmu-events-string.c to .gitignore, declares extern const char big_c_string[];
locally inside output_string_file and output_file when split to prevent linkage
conflicts with empty-pmu-events.c, defers file closures to ensure identical
timestamps, and uses canonical Make 4.0 @: dependency chaining.
- 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). Moves _init_worker to top-level
scope to ensure clean pickling under spawn multiprocessing start methods.
12: 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.
13-14: 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 v6:
- Rebase/resend as last series failed to apply by Sashiko.
Ian Rogers (14):
tools build: Fix feature checks to touch target files on success
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: 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/build/feature/Makefile | 13 +-
tools/perf/.gitignore | 1 +
tools/perf/Build | 2 +
tools/perf/Makefile.config | 19 +-
tools/perf/Makefile.perf | 423 ++----------------
tools/perf/bench/Build | 6 +
.../bpf_skel/bench_uprobe.bpf.c | 0
tools/perf/bench/uprobe.c | 2 +-
tools/perf/bpf_skel.mak | 109 +++++
tools/perf/builtin-trace.c | 32 +-
tools/perf/pmu-events/Build | 26 +-
tools/perf/pmu-events/jevents.py | 59 ++-
tools/perf/trace/beauty/Build | 276 ++++++++++++
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 | 5 +-
tools/perf/trace/beauty/futex_val3.c | 5 +-
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 | 2 +
tools/perf/trace/beauty/perf_event_open.c | 21 +-
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 | 21 +
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 +
38 files changed, 688 insertions(+), 516 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
On Mon, May 18, 2026 at 08:46:24AM -0700, Ian Rogers wrote:
> 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 44%:
>
> Before:
> real 0m29.006s
> user 2m46.019s
> sys 0m30.610s
>
> After:
> real 0m16.091s
> user 2m40.135s
> sys 0m25.740s
>
> Saving 12.9 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.717s
> user 0m1.682s
> sys 0m0.960s
>
> Summary of Patches:
>
> 1: Fast-Path Feature Detection
> - Refactors test-clang-bpf-co-re.bin and test-bpftool-skeletons.bin feature
> checks to group shell pipelines within curly braces and redirect both stdout
> and stderr to .make.output before touching $@ purely upon success
> (> $(@:.bin=.make.output) 2>&1 && touch $@). Grouping the pipeline ({ cmd1 | cmd2; })
> ensures that compiler stderr is successfully captured in .make.output rather
> than escaping to the parent shell. This perfectly matches standard Kbuild
> feature check conventions and ensures the target files are touched on disk
> purely upon success, allowing Kbuild to cache positive detections and avoid
> continuous sub-make re-evaluations during incremental builds. Adds
> test-bpftool-skeletons.bin to the clean FILES list and explicit source
> prerequisite test-clang-bpf-co-re.c.
I think patch 1 can be separated and needs Ack/Review from BPF folks.
>
> 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-7: 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.
> - Ensures benchmark skeleton intermediate .bpf.o files are cleanly removed
> during make clean, and adds bpf-skel-prepare to .PHONY.
>
> 8-9: Foundational Linkage Optimization
> - Moves static libsymbol library prerequisites out of the prepare step.
> - Eliminates redundant libbpf sub-make feature checks during static builds.
>
> 10-11: 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. Adds
> pmu-events-string.c to .gitignore, declares extern const char big_c_string[];
> locally inside output_string_file and output_file when split to prevent linkage
> conflicts with empty-pmu-events.c, defers file closures to ensure identical
> timestamps, and uses canonical Make 4.0 @: dependency chaining.
> - 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). Moves _init_worker to top-level
> scope to ensure clean pickling under spawn multiprocessing start methods.
>
> 12: 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.
>
> 13-14: 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 v6:
> - Rebase/resend as last series failed to apply by Sashiko.
>
> Ian Rogers (14):
> tools build: Fix feature checks to touch target files on success
> 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: 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
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Thanks,
Namhyung
On Tue, May 19, 2026 at 11:27:05AM -0700, Namhyung Kim wrote:
> On Mon, May 18, 2026 at 08:46:24AM -0700, Ian Rogers wrote:
> > 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 44%:
> >
> > Before:
> > real 0m29.006s
> > user 2m46.019s
> > sys 0m30.610s
> >
> > After:
> > real 0m16.091s
> > user 2m40.135s
> > sys 0m25.740s
> >
> > Saving 12.9 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.717s
> > user 0m1.682s
> > sys 0m0.960s
> >
> > Summary of Patches:
> >
> > 1: Fast-Path Feature Detection
> > - Refactors test-clang-bpf-co-re.bin and test-bpftool-skeletons.bin feature
> > checks to group shell pipelines within curly braces and redirect both stdout
> > and stderr to .make.output before touching $@ purely upon success
> > (> $(@:.bin=.make.output) 2>&1 && touch $@). Grouping the pipeline ({ cmd1 | cmd2; })
> > ensures that compiler stderr is successfully captured in .make.output rather
> > than escaping to the parent shell. This perfectly matches standard Kbuild
> > feature check conventions and ensures the target files are touched on disk
> > purely upon success, allowing Kbuild to cache positive detections and avoid
> > continuous sub-make re-evaluations during incremental builds. Adds
> > test-bpftool-skeletons.bin to the clean FILES list and explicit source
> > prerequisite test-clang-bpf-co-re.c.
>
> I think patch 1 can be separated and needs Ack/Review from BPF folks.
>
> >
> > 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-7: 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.
> > - Ensures benchmark skeleton intermediate .bpf.o files are cleanly removed
> > during make clean, and adds bpf-skel-prepare to .PHONY.
> >
> > 8-9: Foundational Linkage Optimization
> > - Moves static libsymbol library prerequisites out of the prepare step.
> > - Eliminates redundant libbpf sub-make feature checks during static builds.
> >
> > 10-11: 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. Adds
> > pmu-events-string.c to .gitignore, declares extern const char big_c_string[];
> > locally inside output_string_file and output_file when split to prevent linkage
> > conflicts with empty-pmu-events.c, defers file closures to ensure identical
> > timestamps, and uses canonical Make 4.0 @: dependency chaining.
> > - 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). Moves _init_worker to top-level
> > scope to ensure clean pickling under spawn multiprocessing start methods.
> >
> > 12: 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.
> >
> > 13-14: 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 v6:
> > - Rebase/resend as last series failed to apply by Sashiko.
> >
> > Ian Rogers (14):
> > tools build: Fix feature checks to touch target files on success
> > 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: 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
>
> Reviewed-by: Namhyung Kim <namhyung@kernel.org>
So this is for 2-14? I haven't checked if 1 can be left out of an
initial merge by me.
- Arnaldo
On Tue, May 19, 2026 at 11:49 AM Arnaldo Carvalho de Melo
<acme@kernel.org> wrote:
>
> On Tue, May 19, 2026 at 11:27:05AM -0700, Namhyung Kim wrote:
> > On Mon, May 18, 2026 at 08:46:24AM -0700, Ian Rogers wrote:
> > > 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 44%:
> > >
> > > Before:
> > > real 0m29.006s
> > > user 2m46.019s
> > > sys 0m30.610s
> > >
> > > After:
> > > real 0m16.091s
> > > user 2m40.135s
> > > sys 0m25.740s
> > >
> > > Saving 12.9 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.717s
> > > user 0m1.682s
> > > sys 0m0.960s
> > >
> > > Summary of Patches:
> > >
> > > 1: Fast-Path Feature Detection
> > > - Refactors test-clang-bpf-co-re.bin and test-bpftool-skeletons.bin feature
> > > checks to group shell pipelines within curly braces and redirect both stdout
> > > and stderr to .make.output before touching $@ purely upon success
> > > (> $(@:.bin=.make.output) 2>&1 && touch $@). Grouping the pipeline ({ cmd1 | cmd2; })
> > > ensures that compiler stderr is successfully captured in .make.output rather
> > > than escaping to the parent shell. This perfectly matches standard Kbuild
> > > feature check conventions and ensures the target files are touched on disk
> > > purely upon success, allowing Kbuild to cache positive detections and avoid
> > > continuous sub-make re-evaluations during incremental builds. Adds
> > > test-bpftool-skeletons.bin to the clean FILES list and explicit source
> > > prerequisite test-clang-bpf-co-re.c.
> >
> > I think patch 1 can be separated and needs Ack/Review from BPF folks.
> >
> > >
> > > 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-7: 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.
> > > - Ensures benchmark skeleton intermediate .bpf.o files are cleanly removed
> > > during make clean, and adds bpf-skel-prepare to .PHONY.
> > >
> > > 8-9: Foundational Linkage Optimization
> > > - Moves static libsymbol library prerequisites out of the prepare step.
> > > - Eliminates redundant libbpf sub-make feature checks during static builds.
> > >
> > > 10-11: 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. Adds
> > > pmu-events-string.c to .gitignore, declares extern const char big_c_string[];
> > > locally inside output_string_file and output_file when split to prevent linkage
> > > conflicts with empty-pmu-events.c, defers file closures to ensure identical
> > > timestamps, and uses canonical Make 4.0 @: dependency chaining.
> > > - 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). Moves _init_worker to top-level
> > > scope to ensure clean pickling under spawn multiprocessing start methods.
> > >
> > > 12: 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.
> > >
> > > 13-14: 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 v6:
> > > - Rebase/resend as last series failed to apply by Sashiko.
> > >
> > > Ian Rogers (14):
> > > tools build: Fix feature checks to touch target files on success
> > > 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: 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
> >
> > Reviewed-by: Namhyung Kim <namhyung@kernel.org>
>
> So this is for 2-14? I haven't checked if 1 can be left out of an
> initial merge by me.
I believe you are correct. Patch 1 is completely independent because
it is the only change in tools/build; everything else is in
tools/perf.
Thanks,
Ian
> - Arnaldo
On Tue, May 19, 2026 at 11:53:08AM -0700, Ian Rogers wrote:
> On Tue, May 19, 2026 at 11:49 AM Arnaldo Carvalho de Melo
> <acme@kernel.org> wrote:
> >
> > On Tue, May 19, 2026 at 11:27:05AM -0700, Namhyung Kim wrote:
> > > On Mon, May 18, 2026 at 08:46:24AM -0700, Ian Rogers wrote:
> > > > 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 44%:
> > > >
> > > > Before:
> > > > real 0m29.006s
> > > > user 2m46.019s
> > > > sys 0m30.610s
> > > >
> > > > After:
> > > > real 0m16.091s
> > > > user 2m40.135s
> > > > sys 0m25.740s
> > > >
> > > > Saving 12.9 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.717s
> > > > user 0m1.682s
> > > > sys 0m0.960s
> > > >
> > > > Summary of Patches:
> > > >
> > > > 1: Fast-Path Feature Detection
> > > > - Refactors test-clang-bpf-co-re.bin and test-bpftool-skeletons.bin feature
> > > > checks to group shell pipelines within curly braces and redirect both stdout
> > > > and stderr to .make.output before touching $@ purely upon success
> > > > (> $(@:.bin=.make.output) 2>&1 && touch $@). Grouping the pipeline ({ cmd1 | cmd2; })
> > > > ensures that compiler stderr is successfully captured in .make.output rather
> > > > than escaping to the parent shell. This perfectly matches standard Kbuild
> > > > feature check conventions and ensures the target files are touched on disk
> > > > purely upon success, allowing Kbuild to cache positive detections and avoid
> > > > continuous sub-make re-evaluations during incremental builds. Adds
> > > > test-bpftool-skeletons.bin to the clean FILES list and explicit source
> > > > prerequisite test-clang-bpf-co-re.c.
> > >
> > > I think patch 1 can be separated and needs Ack/Review from BPF folks.
> > >
> > > >
> > > > 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-7: 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.
> > > > - Ensures benchmark skeleton intermediate .bpf.o files are cleanly removed
> > > > during make clean, and adds bpf-skel-prepare to .PHONY.
> > > >
> > > > 8-9: Foundational Linkage Optimization
> > > > - Moves static libsymbol library prerequisites out of the prepare step.
> > > > - Eliminates redundant libbpf sub-make feature checks during static builds.
> > > >
> > > > 10-11: 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. Adds
> > > > pmu-events-string.c to .gitignore, declares extern const char big_c_string[];
> > > > locally inside output_string_file and output_file when split to prevent linkage
> > > > conflicts with empty-pmu-events.c, defers file closures to ensure identical
> > > > timestamps, and uses canonical Make 4.0 @: dependency chaining.
> > > > - 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). Moves _init_worker to top-level
> > > > scope to ensure clean pickling under spawn multiprocessing start methods.
> > > >
> > > > 12: 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.
> > > >
> > > > 13-14: 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 v6:
> > > > - Rebase/resend as last series failed to apply by Sashiko.
> > > >
> > > > Ian Rogers (14):
> > > > tools build: Fix feature checks to touch target files on success
> > > > 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: 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
> > >
> > > Reviewed-by: Namhyung Kim <namhyung@kernel.org>
> >
> > So this is for 2-14? I haven't checked if 1 can be left out of an
> > initial merge by me.
>
> I believe you are correct. Patch 1 is completely independent because
> it is the only change in tools/build; everything else is in
> tools/perf.
Actually it goes to the patch 1 as well. But we can take 2-14 in the
perf tree first.
Thanks,
Namhyung
On Tue, May 19, 2026 at 05:18:31PM -0700, Namhyung Kim wrote:
> On Tue, May 19, 2026 at 11:53:08AM -0700, Ian Rogers wrote:
> > On Tue, May 19, 2026 at 11:49 AM Arnaldo Carvalho de Melo
> > <acme@kernel.org> wrote:
> > >
> > > On Tue, May 19, 2026 at 11:27:05AM -0700, Namhyung Kim wrote:
> > > > On Mon, May 18, 2026 at 08:46:24AM -0700, Ian Rogers wrote:
> > > > > 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 44%:
> > > > >
> > > > > Before:
> > > > > real 0m29.006s
> > > > > user 2m46.019s
> > > > > sys 0m30.610s
> > > > >
> > > > > After:
> > > > > real 0m16.091s
> > > > > user 2m40.135s
> > > > > sys 0m25.740s
> > > > >
> > > > > Saving 12.9 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.717s
> > > > > user 0m1.682s
> > > > > sys 0m0.960s
> > > > >
> > > > > Summary of Patches:
> > > > >
> > > > > 1: Fast-Path Feature Detection
> > > > > - Refactors test-clang-bpf-co-re.bin and test-bpftool-skeletons.bin feature
> > > > > checks to group shell pipelines within curly braces and redirect both stdout
> > > > > and stderr to .make.output before touching $@ purely upon success
> > > > > (> $(@:.bin=.make.output) 2>&1 && touch $@). Grouping the pipeline ({ cmd1 | cmd2; })
> > > > > ensures that compiler stderr is successfully captured in .make.output rather
> > > > > than escaping to the parent shell. This perfectly matches standard Kbuild
> > > > > feature check conventions and ensures the target files are touched on disk
> > > > > purely upon success, allowing Kbuild to cache positive detections and avoid
> > > > > continuous sub-make re-evaluations during incremental builds. Adds
> > > > > test-bpftool-skeletons.bin to the clean FILES list and explicit source
> > > > > prerequisite test-clang-bpf-co-re.c.
> > > >
> > > > I think patch 1 can be separated and needs Ack/Review from BPF folks.
> > > >
> > > > >
> > > > > 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-7: 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.
> > > > > - Ensures benchmark skeleton intermediate .bpf.o files are cleanly removed
> > > > > during make clean, and adds bpf-skel-prepare to .PHONY.
> > > > >
> > > > > 8-9: Foundational Linkage Optimization
> > > > > - Moves static libsymbol library prerequisites out of the prepare step.
> > > > > - Eliminates redundant libbpf sub-make feature checks during static builds.
> > > > >
> > > > > 10-11: 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. Adds
> > > > > pmu-events-string.c to .gitignore, declares extern const char big_c_string[];
> > > > > locally inside output_string_file and output_file when split to prevent linkage
> > > > > conflicts with empty-pmu-events.c, defers file closures to ensure identical
> > > > > timestamps, and uses canonical Make 4.0 @: dependency chaining.
> > > > > - 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). Moves _init_worker to top-level
> > > > > scope to ensure clean pickling under spawn multiprocessing start methods.
> > > > >
> > > > > 12: 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.
> > > > >
> > > > > 13-14: 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 v6:
> > > > > - Rebase/resend as last series failed to apply by Sashiko.
> > > > >
> > > > > Ian Rogers (14):
> > > > > tools build: Fix feature checks to touch target files on success
> > > > > 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: 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
> > > >
> > > > Reviewed-by: Namhyung Kim <namhyung@kernel.org>
> > >
> > > So this is for 2-14? I haven't checked if 1 can be left out of an
> > > initial merge by me.
> >
> > I believe you are correct. Patch 1 is completely independent because
> > it is the only change in tools/build; everything else is in
> > tools/perf.
>
> Actually it goes to the patch 1 as well. But we can take 2-14 in the
> perf tree first.
Ok, lets go with 2-14, we can look at 1 later.
- Arnaldo
On Tue, May 19, 2026 at 11:27 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Mon, May 18, 2026 at 08:46:24AM -0700, Ian Rogers wrote:
> > 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 44%:
> >
> > Before:
> > real 0m29.006s
> > user 2m46.019s
> > sys 0m30.610s
> >
> > After:
> > real 0m16.091s
> > user 2m40.135s
> > sys 0m25.740s
> >
> > Saving 12.9 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.717s
> > user 0m1.682s
> > sys 0m0.960s
> >
> > Summary of Patches:
> >
> > 1: Fast-Path Feature Detection
> > - Refactors test-clang-bpf-co-re.bin and test-bpftool-skeletons.bin feature
> > checks to group shell pipelines within curly braces and redirect both stdout
> > and stderr to .make.output before touching $@ purely upon success
> > (> $(@:.bin=.make.output) 2>&1 && touch $@). Grouping the pipeline ({ cmd1 | cmd2; })
> > ensures that compiler stderr is successfully captured in .make.output rather
> > than escaping to the parent shell. This perfectly matches standard Kbuild
> > feature check conventions and ensures the target files are touched on disk
> > purely upon success, allowing Kbuild to cache positive detections and avoid
> > continuous sub-make re-evaluations during incremental builds. Adds
> > test-bpftool-skeletons.bin to the clean FILES list and explicit source
> > prerequisite test-clang-bpf-co-re.c.
>
> I think patch 1 can be separated and needs Ack/Review from BPF folks.
So I dropped the patch restricting the features tested when making
bpftool in bootstrap mode as perf does:
https://lore.kernel.org/linux-perf-users/20260514163409.927816-2-irogers@google.com/
We don't need to test for libbfd disassembly support for bpftool if we
just need the bootstrap version. But anyway, I dropped that patch and
hopefully someone on the BPF side can take it or something. I find the
BPF mailing list has a difficult user interface.
The only patch remaining is:
https://lore.kernel.org/linux-perf-users/20260518154638.2798789-2-irogers@google.com/
```
...
-$(OUTPUT)test-clang-bpf-co-re.bin:
- $(CLANG) -S -g --target=bpf -o - $(patsubst %.bin,%.c,$(@F)) | \
- grep BTF_KIND_VAR
+$(OUTPUT)test-clang-bpf-co-re.bin: test-clang-bpf-co-re.c
+ { $(CLANG) -S -g --target=bpf -o - $< | \
+ grep BTF_KIND_VAR; } > $(@:.bin=.make.output) 2>&1 && touch $@
$(OUTPUT)test-file-handle.bin:
$(BUILD)
@@ -393,8 +394,8 @@ $(OUTPUT)test-libopenssl.bin:
$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags openssl 2>/dev/null)
$(OUTPUT)test-bpftool-skeletons.bin:
- $(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons' \
- > $(@:.bin=.make.output) 2>&1
+ { $(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons'; } \
+ > $(@:.bin=.make.output) 2>&1 && touch $@
...
```
which just adds `&& touch $@` so that every incremental build doesn't
re-detect these features. None of the logic changes, so I was hoping
that a BPF sign off wouldn't be a requirement. But anyway, let's hope
a BPF person responds.
> >
> > 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-7: 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.
> > - Ensures benchmark skeleton intermediate .bpf.o files are cleanly removed
> > during make clean, and adds bpf-skel-prepare to .PHONY.
> >
> > 8-9: Foundational Linkage Optimization
> > - Moves static libsymbol library prerequisites out of the prepare step.
> > - Eliminates redundant libbpf sub-make feature checks during static builds.
> >
> > 10-11: 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. Adds
> > pmu-events-string.c to .gitignore, declares extern const char big_c_string[];
> > locally inside output_string_file and output_file when split to prevent linkage
> > conflicts with empty-pmu-events.c, defers file closures to ensure identical
> > timestamps, and uses canonical Make 4.0 @: dependency chaining.
> > - 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). Moves _init_worker to top-level
> > scope to ensure clean pickling under spawn multiprocessing start methods.
> >
> > 12: 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.
> >
> > 13-14: 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 v6:
> > - Rebase/resend as last series failed to apply by Sashiko.
> >
> > Ian Rogers (14):
> > tools build: Fix feature checks to touch target files on success
> > 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: 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
>
> Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Thanks!
Ian
> Thanks,
> Namhyung
>
In tools/build/feature/Makefile, test-clang-bpf-co-re.bin and
test-bpftool-skeletons.bin redirected grep output but never touched or
created the $@ target file upon success.
Because the target file was never created on disk, Kbuild could never cache
the result of the check. Consequently, Make treated the prerequisite as
missing and continuously re-executed the Clang BPF backend and bpftool
feature checks on every single sub-make evaluation during build startup.
Refactor both feature check recipes to group the shell pipeline within
curly braces and redirect both stdout and stderr to .make.output before
touching $@ purely upon success (> $(@:.bin=.make.output) 2>&1 && touch $@).
Grouping the pipeline ({ cmd1 | cmd2; }) ensures that compiler stderr is
successfully captured in .make.output rather than escaping to the parent
shell. This perfectly matches standard Kbuild feature check conventions,
allowing Make to cache positive detections and avoid redundant sub-make
forks during incremental builds. Add test-bpftool-skeletons.bin to the
FILES list so that make clean correctly purges the generated binary. For
test-clang-bpf-co-re.bin, add explicit source file prerequisite
test-clang-bpf-co-re.c and simplify the Clang recipe using $<.
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/feature/Makefile | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 4e4a92ef5e1e..9da5a4fd956a 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -72,7 +72,8 @@ FILES= \
test-file-handle.bin \
test-libpfm4.bin \
test-rust.bin \
- test-libopenssl.bin
+ test-libopenssl.bin \
+ test-bpftool-skeletons.bin
FILES := $(addprefix $(OUTPUT),$(FILES))
@@ -379,9 +380,9 @@ $(OUTPUT)test-libaio.bin:
$(OUTPUT)test-libzstd.bin:
$(BUILD) -lzstd
-$(OUTPUT)test-clang-bpf-co-re.bin:
- $(CLANG) -S -g --target=bpf -o - $(patsubst %.bin,%.c,$(@F)) | \
- grep BTF_KIND_VAR
+$(OUTPUT)test-clang-bpf-co-re.bin: test-clang-bpf-co-re.c
+ { $(CLANG) -S -g --target=bpf -o - $< | \
+ grep BTF_KIND_VAR; } > $(@:.bin=.make.output) 2>&1 && touch $@
$(OUTPUT)test-file-handle.bin:
$(BUILD)
@@ -393,8 +394,8 @@ $(OUTPUT)test-libopenssl.bin:
$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags openssl 2>/dev/null)
$(OUTPUT)test-bpftool-skeletons.bin:
- $(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons' \
- > $(@:.bin=.make.output) 2>&1
+ { $(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons'; } \
+ > $(@:.bin=.make.output) 2>&1 && touch $@
# Testing Rust is special: we don't compile anything, it's enough to check the
# compiler presence. Compiling a test code for this purposes is problematic,
--
2.54.0.563.g4f69b47b94-goog
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 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 an
unconditional top-level recursive kbuild hook (perf-util-y += trace/beauty/)
to compile them into libperf-util.a, resolving remote linkage for util/env.c,
util/bpf-trace-summary.c, and 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 directly inside
generator recipes to guarantee dynamic directory creation before script
redirection, and append 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 | 32 +-
tools/perf/trace/beauty/Build | 276 +++++++++++++++++
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 | 5 +-
tools/perf/trace/beauty/futex_val3.c | 5 +-
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 | 2 +
tools/perf/trace/beauty/perf_event_open.c | 21 +-
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 | 21 ++
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, 447 insertions(+), 368 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 e9cc870a5acd..dbbc9aaccf28 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>
@@ -235,6 +236,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
@@ -777,10 +788,6 @@ 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);
@@ -1129,21 +1136,6 @@ 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",
.arg = { [1] = { .scnprintf = SCA_ACCMODE, /* mode */ }, }, },
diff --git a/tools/perf/trace/beauty/Build b/tools/perf/trace/beauty/Build
index 561590ee8cda..93cde93461a3 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,262 @@ $(OUTPUT)%.shellcheck_log: %
$(Q)$(call echo-cmd,test)$(SHELLCHECK) "$<" > $@ || (cat $@ && rm $@ && false)
perf-y += $(SHELL_TEST_LOGS)
+
+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
+
+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) > $@
+
+$(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..18b661282834 100644
--- a/tools/perf/trace/beauty/eventfd.c
+++ b/tools/perf/trace/beauty/eventfd.c
@@ -1,4 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1
+#include "trace/beauty/beauty.h"
+
#ifndef EFD_SEMAPHORE
#define EFD_SEMAPHORE 1
#endif
@@ -11,7 +13,7 @@
#define EFD_CLOEXEC 02000000
#endif
-static size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct syscall_arg *arg)
+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_";
@@ -35,5 +37,3 @@ 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..05d2111e504b 100644
--- a/tools/perf/trace/beauty/futex_op.c
+++ b/tools/perf/trace/beauty/futex_op.c
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: LGPL-2.1
+#include "trace/beauty/beauty.h"
#include <linux/futex.h>
#ifndef FUTEX_WAIT_BITSET
@@ -17,7 +18,7 @@
#define FUTEX_CLOCK_REALTIME 256
#endif
-static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct syscall_arg *arg)
+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_";
@@ -59,5 +60,3 @@ 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..fe4e82741ffc 100644
--- a/tools/perf/trace/beauty/futex_val3.c
+++ b/tools/perf/trace/beauty/futex_val3.c
@@ -1,11 +1,12 @@
// SPDX-License-Identifier: LGPL-2.1
+#include "trace/beauty/beauty.h"
#include <linux/futex.h>
#ifndef FUTEX_BITSET_MATCH_ANY
#define FUTEX_BITSET_MATCH_ANY 0xffffffff
#endif
-static size_t syscall_arg__scnprintf_futex_val3(char *bf, size_t size, struct syscall_arg *arg)
+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;
@@ -15,5 +16,3 @@ 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..c8a4cd49c845 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,8 @@ 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..9304b0bf3094 100644
--- a/tools/perf/trace/beauty/mode_t.c
+++ b/tools/perf/trace/beauty/mode_t.c
@@ -1,4 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1
+#include "trace/beauty/beauty.h"
+
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -20,7 +22,7 @@
#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)
+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_";
@@ -67,5 +69,3 @@ 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..be7f82677cbf 100644
--- a/tools/perf/trace/beauty/msg_flags.c
+++ b/tools/perf/trace/beauty/msg_flags.c
@@ -1,4 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1
+#include "trace/beauty/beauty.h"
+
#include <sys/types.h>
#include <sys/socket.h>
@@ -27,8 +29,8 @@
# define MSG_CMSG_CLOEXEC 0x40000000
#endif
-static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size,
- struct syscall_arg *arg)
+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_";
@@ -72,5 +74,3 @@ 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..c2c7769e6595 100644
--- a/tools/perf/trace/beauty/open_flags.c
+++ b/tools/perf/trace/beauty/open_flags.c
@@ -1,4 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1
+#include "trace/beauty/beauty.h"
+
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
diff --git a/tools/perf/trace/beauty/perf_event_open.c b/tools/perf/trace/beauty/perf_event_open.c
index 9f1ed989c775..c1c7445dcff9 100644
--- a/tools/perf/trace/beauty/perf_event_open.c
+++ b/tools/perf/trace/beauty/perf_event_open.c
@@ -1,4 +1,8 @@
// SPDX-License-Identifier: LGPL-2.1
+#include "trace/beauty/beauty.h"
+#include "util/evsel_fprintf.h"
+#include <linux/perf_event.h>
+
#ifndef PERF_FLAG_FD_NO_GROUP
# define PERF_FLAG_FD_NO_GROUP (1UL << 0)
#endif
@@ -15,8 +19,8 @@
# 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)
+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 +47,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,19 +80,14 @@ 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);
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..3fb6d9e0fae9 100644
--- a/tools/perf/trace/beauty/sched_policy.c
+++ b/tools/perf/trace/beauty/sched_policy.c
@@ -1,4 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1
+#include "trace/beauty/beauty.h"
+
#include <sched.h>
/*
@@ -14,8 +16,8 @@
#define SCHED_RESET_ON_FORK 0x40000000
#endif
-static size_t syscall_arg__scnprintf_sched_policy(char *bf, size_t size,
- struct syscall_arg *arg)
+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_";
@@ -46,5 +48,3 @@ 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..f345c66c1bfa 100644
--- a/tools/perf/trace/beauty/seccomp.c
+++ b/tools/perf/trace/beauty/seccomp.c
@@ -1,4 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1
+#include "trace/beauty/beauty.h"
+
#ifndef SECCOMP_SET_MODE_STRICT
#define SECCOMP_SET_MODE_STRICT 0
#endif
@@ -6,7 +8,7 @@
#define SECCOMP_SET_MODE_FILTER 1
#endif
-static size_t syscall_arg__scnprintf_seccomp_op(char *bf, size_t size, struct syscall_arg *arg)
+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_";
@@ -51,5 +53,3 @@ 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..6817e9febab9 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 "trace/beauty/beauty.h"
+
#include <signal.h>
-static size_t syscall_arg__scnprintf_signum(char *bf, size_t size, struct syscall_arg *arg)
+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";
@@ -53,5 +55,3 @@ 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..059e3041d338 100644
--- a/tools/perf/trace/beauty/socket_type.c
+++ b/tools/perf/trace/beauty/socket_type.c
@@ -1,4 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1
+#include "trace/beauty/beauty.h"
+
#include <sys/types.h>
#include <sys/socket.h>
@@ -18,7 +20,7 @@
#define SOCK_TYPE_MASK 0xf
#endif
-static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct syscall_arg *arg)
+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_";
@@ -59,5 +61,3 @@ 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..9924ad24a6f1 100644
--- a/tools/perf/trace/beauty/tracepoints/Build
+++ b/tools/perf/trace/beauty/tracepoints/Build
@@ -1,2 +1,23 @@
perf-y += x86_irq_vectors.o
perf-y += x86_msr.o
+
+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..78ead5df985a 100644
--- a/tools/perf/trace/beauty/waitid_options.c
+++ b/tools/perf/trace/beauty/waitid_options.c
@@ -1,9 +1,11 @@
// SPDX-License-Identifier: LGPL-2.1
+#include "trace/beauty/beauty.h"
+
#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)
+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";
@@ -25,5 +27,3 @@ 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 2bb60f50f62d..797d7bc909be 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
@@ -440,3 +440,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..20953ef7b9d8 100644
--- a/tools/perf/util/env.c
+++ b/tools/perf/util/env.c
@@ -635,10 +635,6 @@ 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)
{
#if defined(HAVE_LIBTRACEEVENT)
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
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
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
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 | 54 +++++++++++++++++
tools/perf/util/Build | 15 ++++-
6 files changed, 79 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..373eae7fb72a 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 $(OUTPUT)bench/bpf_skel/.tmp
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..aa04d8b3ee07
--- /dev/null
+++ b/tools/perf/bpf_skel.mak
@@ -0,0 +1,54 @@
+# 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
+
+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 797d7bc909be..4bbc78b1f741 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -441,4 +441,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
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 7a0e372824c6..8437c3f72125 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -681,7 +681,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
ifndef NO_LIBUNWIND
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 373eae7fb72a..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 $(OUTPUT)bench/bpf_skel/.tmp
+ $(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 aa04d8b3ee07..30924ad140c4 100644
--- a/tools/perf/bpf_skel.mak
+++ b/tools/perf/bpf_skel.mak
@@ -35,6 +35,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)
@@ -51,4 +92,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
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 | 8 ++++++--
tools/perf/bpf_skel.mak | 8 ++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index ec0e91bedce1..876065a02de6 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) \
@@ -971,7 +975,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: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare bpf-skel-prepare
.PHONY: python_perf_target
endif # force_fixdep
diff --git a/tools/perf/bpf_skel.mak b/tools/perf/bpf_skel.mak
index 30924ad140c4..7704e7e635d8 100644
--- a/tools/perf/bpf_skel.mak
+++ b/tools/perf/bpf_skel.mak
@@ -15,6 +15,10 @@ ifeq ($(CONFIG_PERF_BPF_SKEL),y)
BPFTOOL := $(SKEL_TOOL_TMP_OUT)/bootstrap/bpftool
VMLINUX_H := $(SKEL_TOOL_OUT)/vmlinux.h
+.PHONY: bpf-skel-prepare
+bpf-skel-prepare: $(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 }') \
@@ -93,6 +97,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
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 876065a02de6..96a68723109f 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 | $(LIBPERF_UTIL)
+$(LIBPERF_BENCH_IN): FORCE prepare $(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
+$(LIBPERF_UTIL_IN): FORCE prepare $(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)
ifdef LIBBPF_STATIC
prepare: $(LIBBPF)
--
2.54.0.563.g4f69b47b94-goog
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 8437c3f72125..26de7528d6ce 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -575,10 +575,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
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.
Add pmu-events-string.c to tools/perf/.gitignore to ensure in-tree Kbuild
runs do not leave untracked generated files in the working directory.
To guarantee 100% backward compatibility with GNU Make 4.0+ (avoiding the
Make 4.3+ grouped target &: syntax which causes older Make versions like
4.2.1 to spawn multiple concurrent jevents.py processes during parallel
builds), implement a robust dependency chaining pattern:
$(PMU_EVENTS_C): $(JEVENTS_DEPS)
$(PMU_EVENTS_STRING_C): $(PMU_EVENTS_C)
@:
This ensures jevents.py is invoked exactly once. If jevents.py aborts
early, Make's .DELETE_ON_ERROR: purges pmu-events.c, guaranteeing that
subsequent Make invocations correctly re-execute the script and overwrite
pmu-events-string.c. In jevents.py, explicitly close output_file first
and output_string_file second at the tail of main() to guarantee that
pmu-events-string.c receives a filesystem timestamp greater than or equal
to pmu-events.c, completely avoiding redundant incremental rebuilds.
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/.gitignore | 1 +
tools/perf/Makefile.perf | 4 ++--
tools/perf/pmu-events/Build | 16 +++++++++++++++-
tools/perf/pmu-events/jevents.py | 23 +++++++++++++++++++----
4 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore
index 0f9451a6e39c..3b968c5158b8 100644
--- a/tools/perf/.gitignore
+++ b/tools/perf/.gitignore
@@ -38,6 +38,7 @@ arch/*/include/generated/
trace/beauty/generated/
pmu-events/arch/common/common/legacy-cache.json
pmu-events/pmu-events.c
+pmu-events/pmu-events-string.c
pmu-events/jevents
pmu-events/metric_test.log
pmu-events/empty-pmu-events.log
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 96a68723109f..b8a81c9749a8 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -925,7 +925,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
@@ -933,7 +933,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..95172a2a851f 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
@@ -224,6 +234,10 @@ 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_C) $(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..7344940e776a 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('extern const char big_c_string[];\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_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)
@@ -1476,6 +1488,9 @@ struct pmu_table_entry {
print_mapping_table(archs)
print_system_mapping_table()
print_metricgroups()
+ _args.output_file.close()
+ if _args.output_string_file:
+ _args.output_string_file.close()
if __name__ == '__main__':
main()
--
2.54.0.563.g4f69b47b94-goog
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. Define the worker
process initializer _init_worker at the top-level module scope to guarantee
flawless pickling and standard event mapping inheritance under spawn
multiprocessing semantics (avoiding AttributeError crashes when spawn is
used instead of fork). 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 7344940e776a..807c42edcd33 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,14 @@ 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 _init_worker(std_events: dict) -> None:
+ global _arch_std_events
+ _arch_std_events = std_events
+
def main() -> None:
global _args
@@ -1459,9 +1471,25 @@ 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)
+
+ 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
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 b8a81c9749a8..fc92d6ceac5b 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
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 95172a2a851f..372773b998e4 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
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 26de7528d6ce..b56fa8419f7d 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -925,11 +925,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
© 2016 - 2026 Red Hat, Inc.