Skip to content

Commit 09048d2

Browse files
Flowdalicanakryiko
authored andcommitted
kbuild,bpf: Pass make jobs' value to pahole
Pass the value of make's -j/--jobs argument to pahole, to avoid out of memory errors and make pahole respect the "jobs" value of make. On systems with little memory but many cores, invoking pahole using -j without argument potentially creates too many pahole instances, causing an out-of-memory situation. Instead, we should pass make's "jobs" value as an argument to pahole's -j, which is likely configured to be (much) lower than the actual core count on such systems. If make was invoked without -j, either via cmdline or MAKEFLAGS, then JOBS will be simply empty, resulting in the existing behavior, as expected. Signed-off-by: Florian Schmaus <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Tested-by: Holger Hoffstätte <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 7b6e5bf commit 09048d2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scripts/Makefile.btf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
pahole-ver := $(CONFIG_PAHOLE_VERSION)
44
pahole-flags-y :=
55

6+
JOBS := $(patsubst -j%,%,$(filter -j%,$(MAKEFLAGS)))
7+
68
ifeq ($(call test-le, $(pahole-ver), 125),y)
79

810
# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
@@ -12,14 +14,14 @@ endif
1214

1315
pahole-flags-$(call test-ge, $(pahole-ver), 121) += --btf_gen_floats
1416

15-
pahole-flags-$(call test-ge, $(pahole-ver), 122) += -j
17+
pahole-flags-$(call test-ge, $(pahole-ver), 122) += -j$(JOBS)
1618

1719
pahole-flags-$(call test-ge, $(pahole-ver), 125) += --skip_encoding_btf_inconsistent_proto --btf_gen_optimized
1820

1921
else
2022

2123
# Switch to using --btf_features for v1.26 and later.
22-
pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs
24+
pahole-flags-$(call test-ge, $(pahole-ver), 126) = -j$(JOBS) --btf_features=encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_func,decl_tag_kfuncs
2325

2426
ifneq ($(KBUILD_EXTMOD),)
2527
module-pahole-flags-$(call test-ge, $(pahole-ver), 126) += --btf_features=distilled_base

0 commit comments

Comments
 (0)