]> git.itanic.dy.fi Git - linux-stable/commit
kbuild: avoid too many execution of scripts/pahole-flags.sh
authorMasahiro Yamada <masahiroy@kernel.org>
Wed, 18 Oct 2023 15:19:48 +0000 (00:19 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Sat, 28 Oct 2023 12:10:08 +0000 (21:10 +0900)
commit72d091846de935e0942a8a0f1fe24ff739d85d76
tree2b5a31b1ed6279d40ffae00e0bea85898bd46373
parent7f6d8f7e43fb516f060cf71672a922031aa5faa9
kbuild: avoid too many execution of scripts/pahole-flags.sh

scripts/pahole-flags.sh is executed so many times.

You can confirm it, 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... ]

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 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>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
MAINTAINERS
Makefile
scripts/Makefile.btf [new file with mode: 0644]
scripts/pahole-flags.sh [deleted file]