bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
To: Masahiro Yamada <masahiroy@kernel.org>, linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	"Alan Maguire" <alan.maguire@oracle.com>,
	"Nicolas Schier" <n.schier@avm.de>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Andreas Hindborg" <a.hindborg@samsung.com>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Gary Guo" <gary@garyguo.net>, "Hao Luo" <haoluo@google.com>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@kernel.org>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Nicolas Schier" <nicolas@fjasle.eu>,
	"Song Liu" <song@kernel.org>,
	"Stanislav Fomichev" <sdf@google.com>,
	"Wedson Almeida Filho" <wedsonaf@gmail.com>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	bpf@vger.kernel.org, rust-for-linux@vger.kernel.org
Subject: Re: [bpf-next PATCH v2 2/4] kbuild: avoid too many execution of scripts/pahole-flags.sh
Date: Sun, 22 Oct 2023 21:33:58 -0300	[thread overview]
Message-ID: <4c926cff-a3f2-445e-9ca2-9effad423cb7@gmail.com> (raw)
In-Reply-To: <20231018151950.205265-2-masahiroy@kernel.org>

On 10/18/23 12:19, 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 <<EOF >> 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 executed 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]
> 
> 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.
> 
> [1]: https://savannah.gnu.org/bugs/index.php?64746
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
> Tested-by: Alan Maguire <alan.maguire@oracle.com>
> Reviewed-by: Nicolas Schier <n.schier@avm.de>
> Tested-by: Miguel Ojeda <ojeda@kernel.org>
> Acked-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> [...]
> @@ -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

Would've used a tab, for legibility sake.

>   include-$(CONFIG_KASAN)		+= scripts/Makefile.kasan
>   include-$(CONFIG_KCSAN)		+= scripts/Makefile.kcsan
>   include-$(CONFIG_KMSAN)		+= scripts/Makefile.kmsan
> [...]
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>

  parent reply	other threads:[~2023-10-23  0:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18 15:19 [bpf-next PATCH v2 1/4] kbuild: remove ARCH_POSTLINK from module builds Masahiro Yamada
2023-10-18 15:19 ` [bpf-next PATCH v2 2/4] kbuild: avoid too many execution of scripts/pahole-flags.sh Masahiro Yamada
2023-10-19  8:47   ` Jiri Olsa
2023-10-23  0:33   ` Martin Rodriguez Reboredo [this message]
2023-10-18 15:19 ` [bpf-next PATCH v2 3/4] kbuild: skip module BTF with one-time check for vmlinux Masahiro Yamada
2023-10-19  8:17   ` Jiri Olsa
2023-10-18 15:19 ` [bpf-next PATCH v2 4/4] kbuild: refactor module BTF rule Masahiro Yamada
2023-10-18 15:49   ` Nicolas Schier
2023-10-19  8:15   ` Jiri Olsa
2023-10-19 22:54     ` Andrii Nakryiko
2023-10-20  7:03       ` Masahiro Yamada
2023-10-20 20:51         ` Andrii Nakryiko
2023-10-21 11:37           ` Masahiro Yamada
2023-10-21 19:33             ` Andrii Nakryiko
2023-10-22 20:23               ` Masahiro Yamada
2023-10-23  3:19                 ` Andrii Nakryiko
2023-10-28 12:00                   ` Masahiro Yamada
2023-10-28 13:36                     ` Jiri Olsa
2023-10-31 18:44                       ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4c926cff-a3f2-445e-9ca2-9effad423cb7@gmail.com \
    --to=yakoyoku@gmail.com \
    --cc=a.hindborg@samsung.com \
    --cc=alan.maguire@oracle.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=gary@garyguo.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=n.schier@avm.de \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=wedsonaf@gmail.com \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).