Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3574481rdg; Tue, 17 Oct 2023 22:02:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwgfxmwl7q6olYGReTaOBk/y7xYnoWmtvxqw7CuuoHwVdQJQa7kKW9Z2zL7Mcx932Mwi9E X-Received: by 2002:a17:90a:e28e:b0:271:ae4f:dd12 with SMTP id d14-20020a17090ae28e00b00271ae4fdd12mr4203565pjz.26.1697605321337; Tue, 17 Oct 2023 22:02:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697605321; cv=none; d=google.com; s=arc-20160816; b=FIMsB52M8YD2SqbDA3dU3iCwM3cxAdFwrGMccbt9BakrZH8GIDu4n7OtCHFNSQqK0a eQ6YYIrzrt3UcyOySxZdTccXN2fXqN045QKEvAVyDjIhAzZjOpPCt02ciT70/JZF37Tp 8BMQKg6aGnCSRCkuDscFT4NcikcsZiapY5H5oijbPxOpTjeIUPLTHHP3IdWvij49vQTK xdPclWAdeVe7rJXFydABlKossZbgCOCgEoE3D2K8GGhBohiLzqkyeyzb35GLSS6krYF9 40rRaSNp5U+DtyUoGik8kMHxKBPexTP+FptAycB/cZf7XdhOp3ZUF/tjz5INvryX0bVD 3dxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=nuJshVKSXKOSG9p7p5Yv97G0onknz3gm27Z2NVa4pak=; fh=IpTZyfX2G9oBkpk9FIWAWOoF8yddrRviu73FWYnUzJ4=; b=Xqa53FfROT3GhUQEYV8EaG0T9EhgQyk42vm2D+qgfDQP8kADav1QZHsj66kkXxYG4O Z2m6YTDDt8kdPeVFAme948I1V87HMxL4FAnDOoY8to0N2LBQHhX0XmquXI7a1OZ5mlsW dDsjbrDD/fxvPWOQRjNAEix7TS86G7vJs+RS6M5oVtMw0z/rny5NGZrLNlPUP9+vXoDO Ikin5CQ0EvqZo1eIh8phL7lDdQHqlcP5MEy/q3UsK2OLVaYiSVsCtqhXLFVh20YNSUw+ jEfwqt9r0ZW/0vlSNbKyEksuzWiWIcsO+k8HUaqS/IVj2FbU3g7ufrcJjKezD5RwGk4F j5Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="g/4pWe2n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id n3-20020a17090a9f0300b0026b31ed4895si728475pjp.29.2023.10.17.22.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 22:02:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="g/4pWe2n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 01F85806923B; Tue, 17 Oct 2023 22:01:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229455AbjJRFBZ (ORCPT + 99 others); Wed, 18 Oct 2023 01:01:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjJRFBX (ORCPT ); Wed, 18 Oct 2023 01:01:23 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3C0FB0; Tue, 17 Oct 2023 22:01:20 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FD36C433C9; Wed, 18 Oct 2023 05:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697605280; bh=Ckyy2X8tBufClleOPA0RjLMRbz7/6JEOlB60UkusMtY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=g/4pWe2nCuSagq3vXanNy/QZAviLnpWaj01hJmNoNlji0LWf96xAd0ijVUsBVgm7G yTy/wdw81JDFErcKM+jKdZT1YMzL3FME33hgxLDzlpVDhK1BXcOKqYeTj58nLXQ1AE XNx9VE7gRsArPBWRHb86u/h8VDXXXfDWtiDQKlBBPO538DzHdDqEWuBUCIS7cmPb0T WQodJtEFeQFYMYJpMJP9M2/cOjmcPHUKPEcFwrzHWapGSEKxaX76XX2hlVGAKQvGoP gKm9ZKxHHpHETDYGWWKogoDUopeJNFvX907SqpIGimdfFSFNql7Lt1BzmTQQJmMxKB JFbijesgJtq3A== Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-1ea82246069so968682fac.3; Tue, 17 Oct 2023 22:01:20 -0700 (PDT) X-Gm-Message-State: AOJu0YzafLWQfQkiGKqmJOo/5k7ARk6QZykTOf3jzdAfwYBkDZQKDuCQ DgGzWKgP+JwYXaRDJBCAEcksN//2l468SI3egy8= X-Received: by 2002:a05:6870:15d5:b0:1e9:87ce:133e with SMTP id k21-20020a05687015d500b001e987ce133emr5184202oad.8.1697605279568; Tue, 17 Oct 2023 22:01:19 -0700 (PDT) MIME-Version: 1.0 References: <20231017103742.130927-1-masahiroy@kernel.org> <20231017103742.130927-2-masahiroy@kernel.org> In-Reply-To: From: Masahiro Yamada Date: Wed, 18 Oct 2023 14:00:42 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/4] kbuild: avoid too many execution of scripts/pahole-flags.sh To: Andrii Nakryiko Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Alex Gaynor , Alexei Starovoitov , Alice Ryhl , Andreas Hindborg , Andrii Nakryiko , Benno Lossin , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Boqun Feng , Daniel Borkmann , Gary Guo , Hao Luo , Jiri Olsa , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 17 Oct 2023 22:01:47 -0700 (PDT) On Wed, Oct 18, 2023 at 4:57=E2=80=AFAM Andrii Nakryiko wrote: > > On Tue, Oct 17, 2023 at 3:38=E2=80=AFAM 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 >=3D 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] > > > > 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=3Dy. > > > > [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 =3D lz4c > > XZ =3D xz > > ZSTD =3D zstd > > > > -PAHOLE_FLAGS =3D $(shell PAHOLE=3D$(PAHOLE) $(srctree)/scripts/pahol= e-flags.sh) > > What if we just used :=3D here? Wouldn't it avoid unnecessary multiple ex= ecutions? Yeah, :=3D is less silly than =3D. But, I do not like to run the script for non-build targets such as 'make clean', 'make help', etc. Also, when building with CONFIG_DEBUG_INFO_BTF=3Dn, the shell is forked to compute PAHOLE_FLAGS, which we know are unnecessary. -- Best Regards Masahiro Yamada