Linux kbuild/kconfig development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hamdy Abou El Anein" <info@daylightlinux.ch>, nathan@kernel.org
Cc: nsc@kernel.org, linux-kbuild@vger.kernel.org, hamdy.aea@protonmail.com
Subject: Re: [PATCH] scripts: check-function-names: propagate nm failures
Date: Wed, 04 Nov 2026 10:58:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-197134@kernel.org> (raw)
In-Reply-To: <20261103105829.10511-1-info@daylightlinux.ch>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] scripts: check-function-names: buffering full vmlinux.o nm output in shell
--

commit 329efcc5adb68fe0ddbe8ccd5ee716b893c4188e
Author: Hamdy Abou El Anein <hamdy.aea@protonmail.com>

scripts: check-function-names: propagate nm failures

This commit captures the output of nm in a shell variable before piping it
to awk and grep so that check-function-names.sh exits with an error if nm
fails on the input object file.

> diff --git a/scripts/check-function-names.sh b/scripts/check-function-names.sh
> index 94883e690627d..f07a0e1cf3394 100755
> --- a/scripts/check-function-names.sh
> +++ b/scripts/check-function-names.sh
> @@ -13,7 +13,8 @@ if [ ! -f "$objfile" ]; then
>  	exit 1
>  fi
>  
> -bad_symbols=$(${NM:-nm} -p "$objfile" | awk '$2 ~ /^[TtWw]$/ {print $3}' |
> +symbols=$(${NM:-nm} -p "$objfile") || exit 1
> +bad_symbols=$(printf '%s\n' "$symbols" | awk '$2 ~ /^[TtWw]$/ {print $3}' |
>  	      grep -E '^(startup|exit|split|unlikely|hot|unknown)(\.|$)')

[Severity: Medium]
Does capturing the entire nm output into symbols and expanding it into
printf introduce a build-time performance and memory regression when linking
vmlinux.o?

In scripts/Makefile.vmlinux_o, rule_ld_vmlinux.o runs this script on
vmlinux.o in the serial path of the kernel link:

scripts/Makefile.vmlinux_o:
cmd_check_function_names = $(srctree)/scripts/check-function-names.sh $@

define rule_ld_vmlinux.o
	$(call cmd_and_savecmd,ld_vmlinux.o)
	$(call cmd,gen_objtooldep)
	$(call cmd,check_function_names)
endef

Because vmlinux.o contains the full built-in kernel symbol table (spanning
many megabytes and hundreds of thousands of symbols, especially on
allmodconfig or allyesconfig builds), previously nm -p streamed directly
into awk in parallel and command substitution only buffered the matching
bad_symbols output (which is empty in the normal case).

With this change, the shell waits for nm to finish while buffering the
entire multi-megabyte symbol table in the symbols variable, and then forks a
subshell that expands and copies the entire string as an argument to printf
before piping it to awk, working against the serial link optimization in
commit c2970d8b52d1 ("kbuild: do not sort nm output where the order is
irrelevant").

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103105829.10511-1-info@daylightlinux.ch?part=1

  reply	other threads:[~2026-11-04 10:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 10:58 [PATCH] scripts: check-function-names: propagate nm failures Hamdy Abou El Anein
2026-11-04 10:58 ` sashiko-bot [this message]
2026-11-04 12:03 ` [PATCH v2] " Hamdy Abou El Anein
2026-11-04 12:07   ` [PATCH v3] " Hamdy Abou El Anein
2026-11-04 23:26     ` Nathan Chancellor
2026-11-05 13:02       ` Hamdy Abou El Anein

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=sashiko-outbox-197134@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=hamdy.aea@protonmail.com \
    --cc=info@daylightlinux.ch \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=sashiko-reviews@lists.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