Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3114651rdg; Tue, 17 Oct 2023 05:17:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG137X/qUdRqoywJhH/W4wF6HCCWYFSZcZh0rQQWhInAHfRNFRf9nZ55S4kDJRylN9WmdY+ X-Received: by 2002:a05:6300:8083:b0:14e:509:1d7b with SMTP id ap3-20020a056300808300b0014e05091d7bmr1800819pzc.8.1697545025937; Tue, 17 Oct 2023 05:17:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697545025; cv=none; d=google.com; s=arc-20160816; b=AzZ3WzJneOinixbF+iS6iS42tu0Op7ESOX7qDFQZibwpdn48fQQz+VMA/SJBTE0YBJ 6BkHFbPLNzv1zScHbocAhAAm7b913OHa1YcClJeluc+53elBe7koNqt+LzlZMAb2DKtW ca281ZjuIv9ftT6x0ERBzUZtM29R5QqLbxbo5ZEQPA+H1cN3ijdTnNTIyFM3idP1IDiX k88qyiImjWKkn/p2JOPP03OrOHBbNj/Zzi0jUdLYtxMhRfVhzKdqmRMKv5L7Dm7LriIs nKPyoYHrYfxaCaZHjWtwlFRkJmlgkDDC6D1auR2PpPdImnuQ0Jd1rIP5Q7PHXZeKUHXs XExA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:date:from:dkim-signature; bh=gz2J8/viNOWHCJxpoa1uLouYnvMF+ug9wHlLJn4++E0=; fh=Fo0JpDj6U+qiO9U5PHBh4lqRDfGZFNe4kjHQxaHX61E=; b=En8CtkdrruzrzUlS3eTlp7PIQIeH1bZW48GFp0TwHExZJhfUBuufULMAUe2LjbW2bg S9A5VqDTB+B+KHk3mbNc7eBEbalNU6Bg4Bk9S9LGW5kffMkCr3IRrkoorAH5yQ8xJHHF N8sjTgzagPhIhwj++mOv6Acp2plcRbn+LwRZWVXHUyXPLRnG5DsKQA00UX7I4k2rkByx bLX0oGCN8y9PWDuZgqYl/7JzSy4P8G/fIjAMoO+XQXoI1f+9593foW2rSsinXVRZg4bN vzSvMmCpe9S4Z9yIfDM6mE4rnwZoyhFk+IygLA6HKdN4G/IDosDksIpEZbrkT5ThfLRg iK0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ITpAt+AJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id f7-20020a17090ac28700b002792c288cc2si1545542pjt.170.2023.10.17.05.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 05:17:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ITpAt+AJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 969EC80AA338; Tue, 17 Oct 2023 05:17:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343552AbjJQMQs (ORCPT + 99 others); Tue, 17 Oct 2023 08:16:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343656AbjJQMQh (ORCPT ); Tue, 17 Oct 2023 08:16:37 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F52A6EAF; Tue, 17 Oct 2023 05:15:45 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-533d31a8523so9525473a12.1; Tue, 17 Oct 2023 05:15:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697544944; x=1698149744; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:from:to:cc:subject:date:message-id:reply-to; bh=gz2J8/viNOWHCJxpoa1uLouYnvMF+ug9wHlLJn4++E0=; b=ITpAt+AJeEWfqNsLcBu3siWdj9LRqdj1XJ+s0ecp5OhkfxbpnH/GDh+X9LMvefy0Fk xXo6M/mj02SzJs1lDTzHktdozm8aHVPUbGYYRQ0TxASv6x69asbwJpIsABLRzj+Kepim EwPwc2ZOrMkfACRtw8M2iNuq/zmkznh9GVuNpxRQvff0stYFfieb+fW2BNXS5Xen4yQt F+Pb+nBtytpLpkIuwvBae10Vkba9cUvahb8gsGNFNtTmoA65Q6lVxnEamj+Z68m0CDBj B9iK0G1BzPev/CQOOjy9QR0cmVE0j5ufBk1FIDyK55+GfbS2Z9JA+4y7QoKW7s0vErWK K3VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697544944; x=1698149744; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:date:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gz2J8/viNOWHCJxpoa1uLouYnvMF+ug9wHlLJn4++E0=; b=e+R3nnR33KFBoKhZN6TqqAmvVeuLz3J6eOGuDVEQokZZTCRQEoUoaPWdJhpZgR3+Ow ID03V4VT2vUP32JjSvSxIDzHZ737hNtjVSNh/Z9es2W/OblQ0XV4APr/W3quhvrvzi8G 3/lEkhTaXFYLPSBvJIudoWicU3hsUKHlexHaC0WLSx+Jw/eY05oL15LR2FM6BnXZCTLU kDAsqNZ/WqxkeQgcicX/g5yJ7F9s8iDwjBsTNfKISfm15tzDq7BZPRNCdcq5Hx2eKym6 nuvvhllF0WmSBNNKXwzvJmwo1GEbUT/cNEip0MsS3qwRv6Zl7MF2VxEI5G7VtIkIeIIi T+0Q== X-Gm-Message-State: AOJu0YyINtuxlWcq8G7uEu+z2Qs98byklivQ2IAtCFvDaYvHlLBXl2jh rSoU2zdTlunWhSMHda3bJHg= X-Received: by 2002:a05:6402:510d:b0:53d:e8a7:57a6 with SMTP id m13-20020a056402510d00b0053de8a757a6mr1716689edd.34.1697544943477; Tue, 17 Oct 2023 05:15:43 -0700 (PDT) Received: from krava (2001-1ae9-1c2-4c00-726e-c10f-8833-ff22.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:726e:c10f:8833:ff22]) by smtp.gmail.com with ESMTPSA id i27-20020a50d75b000000b0053e3d8f1d9fsm1119801edj.67.2023.10.17.05.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 05:15:43 -0700 (PDT) From: Jiri Olsa X-Google-Original-From: Jiri Olsa Date: Tue, 17 Oct 2023 14:15:40 +0200 To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Alex Gaynor , Alexei Starovoitov , Alice Ryhl , Andreas Hindborg , Andrii Nakryiko , Benno Lossin , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Boqun Feng , Daniel Borkmann , Gary Guo , Hao Luo , John Fastabend , KP Singh , Martin KaFai Lau , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Song Liu , Stanislav Fomichev , Wedson Almeida Filho , Yonghong Song , bpf@vger.kernel.org, rust-for-linux@vger.kernel.org Subject: Re: [PATCH 2/4] kbuild: avoid too many execution of scripts/pahole-flags.sh Message-ID: References: <20231017103742.130927-1-masahiroy@kernel.org> <20231017103742.130927-2-masahiroy@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231017103742.130927-2-masahiroy@kernel.org> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 17 Oct 2023 05:17:02 -0700 (PDT) On Tue, Oct 17, 2023 at 07:37:40PM +0900, Masahiro Yamada wrote: > scripts/pahole-flags.sh is executed so many times. > > You can check how many times it is invoked during the build, as follows: > > $ cat <> scripts/pahole-flags.sh > > echo "scripts/pahole-flags.sh was executed" >&2 > > EOF > > $ make -s > scripts/pahole-flags.sh was executed > scripts/pahole-flags.sh was executed > scripts/pahole-flags.sh was executed > scripts/pahole-flags.sh was executed > scripts/pahole-flags.sh was executed > [ lots of repeated lines suppressed... ] > > This scripts is exectuted more than 20 times during the kernel build > because PAHOLE_FLAGS is a recursively expanded variable and exported > to sub-processes. > > With the GNU Make >= 4.4, it is executed more than 60 times because > exported variables are also passed to other $(shell ) invocations. > Without careful coding, it is known to cause an exponential fork > explosion. [1] nice :-\ > > The use of $(shell ) in an exported recursive variable is likely wrong > because $(shell ) is always evaluated due to the 'export' keyword, and > the evaluation can occur multiple times by the nature of recursive > variables. > > Convert the shell script to a Makefile, which is included only when > CONFIG_DEBUG_INFO_BTF=y. looks good.. could you please resend this patch with bpf-next in subject so CI tests would trigger for it? thanks, jirka > > [1]: https://savannah.gnu.org/bugs/index.php?64746 > > Signed-off-by: Masahiro Yamada > --- > > Makefile | 4 +--- > scripts/Makefile.btf | 19 +++++++++++++++++++ > scripts/pahole-flags.sh | 30 ------------------------------ > 3 files changed, 20 insertions(+), 33 deletions(-) > create mode 100644 scripts/Makefile.btf > delete mode 100755 scripts/pahole-flags.sh > > diff --git a/Makefile b/Makefile > index fed9a6cc3665..eaddec67e5e1 100644 > --- a/Makefile > +++ b/Makefile > @@ -513,8 +513,6 @@ LZ4 = lz4c > XZ = xz > ZSTD = zstd > > -PAHOLE_FLAGS = $(shell PAHOLE=$(PAHOLE) $(srctree)/scripts/pahole-flags.sh) > - > CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ > -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF) > NOSTDINC_FLAGS := > @@ -605,7 +603,6 @@ export KBUILD_RUSTFLAGS RUSTFLAGS_KERNEL RUSTFLAGS_MODULE > export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE > export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_RUSTFLAGS_MODULE KBUILD_LDFLAGS_MODULE > export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL KBUILD_RUSTFLAGS_KERNEL > -export PAHOLE_FLAGS > > # Files to ignore in find ... statements > > @@ -1002,6 +999,7 @@ KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) > # include additional Makefiles when needed > include-y := scripts/Makefile.extrawarn > include-$(CONFIG_DEBUG_INFO) += scripts/Makefile.debug > +include-$(CONFIG_DEBUG_INFO_BTF)+= scripts/Makefile.btf > include-$(CONFIG_KASAN) += scripts/Makefile.kasan > include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan > include-$(CONFIG_KMSAN) += scripts/Makefile.kmsan > diff --git a/scripts/Makefile.btf b/scripts/Makefile.btf > new file mode 100644 > index 000000000000..82377e470aed > --- /dev/null > +++ b/scripts/Makefile.btf > @@ -0,0 +1,19 @@ > +# SPDX-License-Identifier: GPL-2.0 > + > +pahole-ver := $(CONFIG_PAHOLE_VERSION) > +pahole-flags-y := > + > +# pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars > +ifeq ($(call test-le, $(pahole-ver), 121),y) > +pahole-flags-$(call test-ge, $(pahole-ver), 118) += --skip_encoding_btf_vars > +endif > + > +pahole-flags-$(call test-ge, $(pahole-ver), 121) += --btf_gen_floats > + > +pahole-flags-$(call test-ge, $(pahole-ver), 122) += -j > + > +pahole-flags-$(CONFIG_PAHOLE_HAS_LANG_EXCLUDE) += --lang_exclude=rust > + > +pahole-flags-$(call test-ge, $(pahole-ver), 125) += --skip_encoding_btf_inconsistent_proto --btf_gen_optimized > + > +export PAHOLE_FLAGS := $(pahole-flags-y) > diff --git a/scripts/pahole-flags.sh b/scripts/pahole-flags.sh > deleted file mode 100755 > index 728d55190d97..000000000000 > --- a/scripts/pahole-flags.sh > +++ /dev/null > @@ -1,30 +0,0 @@ > -#!/bin/sh > -# SPDX-License-Identifier: GPL-2.0 > - > -extra_paholeopt= > - > -if ! [ -x "$(command -v ${PAHOLE})" ]; then > - exit 0 > -fi > - > -pahole_ver=$($(dirname $0)/pahole-version.sh ${PAHOLE}) > - > -if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then > - # pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars > - extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_vars" > -fi > -if [ "${pahole_ver}" -ge "121" ]; then > - extra_paholeopt="${extra_paholeopt} --btf_gen_floats" > -fi > -if [ "${pahole_ver}" -ge "122" ]; then > - extra_paholeopt="${extra_paholeopt} -j" > -fi > -if [ "${pahole_ver}" -ge "124" ]; then > - # see PAHOLE_HAS_LANG_EXCLUDE > - extra_paholeopt="${extra_paholeopt} --lang_exclude=rust" > -fi > -if [ "${pahole_ver}" -ge "125" ]; then > - extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_inconsistent_proto --btf_gen_optimized" > -fi > - > -echo ${extra_paholeopt} > -- > 2.40.1 >