From nobody Sun Nov 24 20:02:19 2024 Received: from zulu.geekplace.eu (zulu.geekplace.eu [5.45.100.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02F3E16FF3B; Sat, 2 Nov 2024 10:16:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=5.45.100.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730542582; cv=none; b=ekfh0ITP56+/tGLe68KTytLv6zMtONPuruBZDUSz99JnVs14uducRMdX6YPGG1e3de7YSyVRKzgM5h9ZnIogTEYEBstzrv+AMmcaw5s0RdV5N4vxQWSKGRzQirsPTt4ySn8Jf1a1ws/Lh/C2xxhY0JRhSu657NeqssOZAV+Yr1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730542582; c=relaxed/simple; bh=lq3SCdtwAoRG1X0Xf16GvmV78s1YX00UVljTHU9wKtY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=WR4CSboCbU4fab3N0o4p8RXH01tSYLKmaPavZR3lo9Kb15oBLxwlXQGytnHTzrq7mtZ/xOcqimfSACeZXzhFmfxFliVo7Own2iujcdOGYHOqE+2o8wm9QJCiBhecZFFnvz9cuWELMBruEY5mc9NcW5DAzsRfP53W8hQU3AfF368= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=geekplace.eu; spf=pass smtp.mailfrom=geekplace.eu; arc=none smtp.client-ip=5.45.100.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=geekplace.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=geekplace.eu Received: from neo-pc.sch (unknown [IPv6:2001:4091:a241:81f5:34fb:50ff:feac:591b]) by zulu.geekplace.eu (Postfix) with ESMTPA id BD9604A0017; Sat, 2 Nov 2024 11:04:56 +0100 (CET) From: Florian Schmaus To: Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Cc: Florian Schmaus , bpf@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] kbuild,bpf: pass make jobs' value to pahole Date: Sat, 2 Nov 2024 11:04:51 +0100 Message-ID: <20241102100452.793970-1-flo@geekplace.eu> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Tested-by: Holger Hoffst=C3=A4tte --- scripts/Makefile.btf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.btf b/scripts/Makefile.btf index b75f09f3f424..c3cbeb13de50 100644 --- a/scripts/Makefile.btf +++ b/scripts/Makefile.btf @@ -3,6 +3,8 @@ pahole-ver :=3D $(CONFIG_PAHOLE_VERSION) pahole-flags-y :=3D =20 +JOBS :=3D $(patsubst -j%,%,$(filter -j%,$(MAKEFLAGS))) + ifeq ($(call test-le, $(pahole-ver), 125),y) =20 # pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars @@ -12,14 +14,14 @@ endif =20 pahole-flags-$(call test-ge, $(pahole-ver), 121) +=3D --btf_gen_floats =20 -pahole-flags-$(call test-ge, $(pahole-ver), 122) +=3D -j +pahole-flags-$(call test-ge, $(pahole-ver), 122) +=3D -j$(JOBS) =20 pahole-flags-$(call test-ge, $(pahole-ver), 125) +=3D --skip_encoding_btf_= inconsistent_proto --btf_gen_optimized =20 else =20 # Switch to using --btf_features for v1.26 and later. -pahole-flags-$(call test-ge, $(pahole-ver), 126) =3D -j --btf_features=3D= encode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consistent_f= unc,decl_tag_kfuncs +pahole-flags-$(call test-ge, $(pahole-ver), 126) =3D -j$(JOBS) --btf_feat= ures=3Dencode_force,var,float,enum64,decl_tag,type_tag,optimized_func,consi= stent_func,decl_tag_kfuncs =20 ifneq ($(KBUILD_EXTMOD),) module-pahole-flags-$(call test-ge, $(pahole-ver), 126) +=3D --btf_feature= s=3Ddistilled_base --=20 2.45.2