Linux kbuild/kconfig development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
	"Linus Torvalds" <torvalds@linux-foundation.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nicolas Schier" <nsc@kernel.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Bill Wendling" <morbo@google.com>,
	"Justin Stitt" <justinstitt@google.com>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	"Petr Pavlu" <petr.pavlu@suse.com>,
	"Daniel Gomez" <da.gomez@kernel.org>,
	"Sami Tolvanen" <samitolvanen@google.com>,
	"Aaron Tomlin" <atomlin@atomlin.com>,
	"Josh Poimboeuf" <jpoimboe@kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	"Nicolas Schier" <n.schier@fritz.com>,
	"Kees Cook" <kees@kernel.org>
Cc: linux-kbuild@vger.kernel.org, linux-m68k@lists.linux-m68k.org,
	linux-modules@vger.kernel.org
Subject: Re: [PATCH v6 3/7] modpost: cache section relocation mismatch state
Date: Wed, 25 Nov 2026 12:21:36 +0000	[thread overview]
Message-ID: <sashiko-outbox-233361@kernel.org> (raw)
In-Reply-To: <20261124-build-speedup-v6-3-141a4f861c67@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] modpost: O(num_sections^2) cache reset in check_sec_ref()
--

commit 5f25a8268ae38882b32798d9f25f701a7e196767
Author: Lorenzo Stoakes (ARM) <ljs@kernel.org>

modpost: cache section relocation mismatch state

This commit caches section_mismatch() results per destination section index
while scanning each relocation section in check_sec_ref().

> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 75374c64b8cc7..83caf29b4bf2b 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1155,12 +1155,62 @@ static void check_export_symbol(struct module *mod, struct elf_info *elf,
>  			 name);
>  }
>  
> +static void init_mismatch_cache(struct elf_info *elf)
> +{
> +	elf->mismatch_cache = xcalloc(elf->num_sections,
> +				      sizeof(*elf->mismatch_cache));
> +}
> +
> +static void reset_mismatch_cache(struct elf_info *elf)
> +{
> +	memset(elf->mismatch_cache, 0,
> +	       elf->num_sections * sizeof(*elf->mismatch_cache));
> +}

[ ... ]

> @@ -1445,6 +1495,8 @@ static void check_sec_ref(struct module *mod, struct elf_info *elf)
>  {
>  	int i;
>  
> +	init_mismatch_cache(elf);
> +
>  	/* Walk through all sections */
>  	for (i = 0; i < elf->num_sections; i++) {
>  		Elf_Shdr *sechdr = &elf->sechdrs[i];
> @@ -1461,6 +1513,9 @@ static void check_sec_ref(struct module *mod, struct elf_info *elf)
>  			if (match(secname, section_white_list))
>  				continue;
>  
> +			/* Reset cache per-section. */
> +			reset_mismatch_cache(elf);

[Severity: Medium]
Does calling reset_mismatch_cache() on every non-whitelisted relocation
section make check_sec_ref() O(elf->num_sections^2)?

When per-function or per-data sections are enabled (for example with
CONFIG_LD_DEAD_CODE_DATA_ELIMINATION or CONFIG_LTO_CLANG), each function
or variable with relocations gets its own .rela.text.<func> or
.rela.data.<var> section in vmlinux.o.  With hundreds of thousands of
sections, zeroing the entire elf->num_sections array per relocation section
performs tens to hundreds of gigabytes of memset() work while flushing
cached entries between .text.* sections that share the same sectioncheck[]
source classification.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261124-build-speedup-v6-0-141a4f861c67@kernel.org?part=3

  reply	other threads:[~2026-11-25 12:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 12:20 [PATCH v6 0/7] kbuild: significantly speed up kernel builds Lorenzo Stoakes (ARM)
2026-11-24 12:20 ` [PATCH v6 1/7] kbuild: calculate list, composite object state per object Lorenzo Stoakes (ARM)
2026-11-24 12:20 ` [PATCH v6 2/7] kbuild: implement and use depcheck to check dependency timestamps Lorenzo Stoakes (ARM)
2026-11-25 12:21   ` sashiko-bot
2026-11-24 12:20 ` [PATCH v6 3/7] modpost: cache section relocation mismatch state Lorenzo Stoakes (ARM)
2026-11-25 12:21   ` sashiko-bot [this message]
2026-11-24 12:20 ` [PATCH v6 4/7] modpost: emit module descriptors as assembly Lorenzo Stoakes (ARM)
2026-11-24 12:20 ` [PATCH v6 5/7] kbuild: batch module finalisation Lorenzo Stoakes (ARM)
2026-11-25  9:56   ` Nicolas Schier
2026-11-25 12:28     ` Lorenzo Stoakes (ARM)
2026-11-24 12:20 ` [PATCH v6 6/7] rust: make exports.o depend on the headers generated for it Lorenzo Stoakes (ARM)
2026-11-24 12:20 ` [PATCH v6 7/7] kbuild: build rust crates in parallel with the rest of the build Lorenzo Stoakes (ARM)
2026-11-25 10:02 ` [PATCH v6 0/7] kbuild: significantly speed up kernel builds Nicolas Schier

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-233361@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=atomlin@atomlin.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=da.gomez@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=geert@linux-m68k.org \
    --cc=jpoimboe@kernel.org \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=lossin@kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=morbo@google.com \
    --cc=n.schier@fritz.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nsc@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=peterz@infradead.org \
    --cc=petr.pavlu@suse.com \
    --cc=samitolvanen@google.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=torvalds@linux-foundation.org \
    --cc=work@onurozkan.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