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