perf build: Pre-generate BPF skeleton tooling during umbrella prepare phase

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.

Reviewed-by: Namhyung Kim <[email protected]>
Assisted-by: Gemini:gemini-3.1-pro-preview
Signed-off-by: Ian Rogers <[email protected]>
Tested-by: James Clark <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Albert Ou <[email protected]>
Cc: Alexandre Chartre <[email protected]>
Cc: Alexandre Ghiti <[email protected]>
Cc: Andrii Nakryiko <[email protected]>
Cc: Ankur Arora <[email protected]>
Cc: Collin Funk <[email protected]>
Cc: Costa Shulyupin <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: Dapeng Mi <[email protected]>
Cc: David Sterba <[email protected]>
Cc: Dmitrii Dolgov <[email protected]>
Cc: Eduard Zingerman <[email protected]>
Cc: Howard Chu <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Kumar Kartikeya Dwivedi <[email protected]>
Cc: Leo Yan <[email protected]>
Cc: Markus Mayer <[email protected]>
Cc: Martin KaFai Lau <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Nick Terrell <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: Paul Walmsley <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Quentin Monnet <[email protected]>
Cc: Ricky Ringler <[email protected]>
Cc: Song Liu <[email protected]>
Cc: Swapnil Sapkal <[email protected]>
Cc: Thomas Falcon <[email protected]>
Cc: Tomas Glozar <[email protected]>
Cc: Yonghong Song <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
Ian Rogers authored and Arnaldo Carvalho de Melo committed 2026-05-20 17:46:45 -03:00
1 parent 9798ac0128
commit 32969ef6e3
2 files changed
+14 -2

No files matched your search

+6 -2
View File
@@ -275,7 +275,7 @@ ifeq ($(PYLINT),1)
endif
export srctree OUTPUT RM CC CXX RUSTC CLANG LD AR CFLAGS CXXFLAGS RUST_FLAGS V BISON FLEX AWK LIBBPF READELF
export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT
export HOSTCC HOSTLD HOSTAR HOSTCFLAGS SHELLCHECK MYPY PYLINT CONFIG_PERF_BPF_SKEL
include $(srctree)/tools/build/Makefile.include
@@ -629,8 +629,12 @@ endif
__build-dir = $(subst $(OUTPUT),,$(dir $@))
build-dir = $(or $(__build-dir),.)
bpf-skel-prepare:
$(Q)$(MAKE) -f bpf_skel.mak bpf-skel-prepare
prepare: $(OUTPUT)PERF-VERSION-FILE \
arm64-sysreg-defs \
bpf-skel-prepare \
$(LIBAPI) \
$(LIBPERF) \
$(LIBSUBCMD) \
@@ -971,7 +975,7 @@ FORCE:
.PHONY: all install clean config-clean strip install-gtk
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare
.PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare bpf-skel-prepare
.PHONY: python_perf_target
endif # force_fixdep
+8
View File
@@ -15,6 +15,10 @@ ifeq ($(CONFIG_PERF_BPF_SKEL),y)
BPFTOOL := $(SKEL_TOOL_TMP_OUT)/bootstrap/bpftool
VMLINUX_H := $(SKEL_TOOL_OUT)/vmlinux.h
.PHONY: bpf-skel-prepare
bpf-skel-prepare: $(BPFTOOL) $(VMLINUX_H)
@:
define get_sys_includes
$(shell $(1) $(2) -v -E - </dev/null 2>&1 \
| sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \
@@ -93,6 +97,10 @@ $(SKEL_OUT)/%.skel.h: $(SKEL_TMP_OUT)/%.bpf.o $(BPFTOOL)
.PRECIOUS: $(SKEL_TMP_OUT)/%.bpf.o
else # CONFIG_PERF_BPF_SKEL
.PHONY: bpf-skel-prepare
bpf-skel-prepare:
@:
endif # CONFIG_PERF_BPF_SKEL
clean: