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 v7 4/7] modpost: emit module descriptors as assembly
Date: Sat, 05 Dec 2026 20:29:05 +0000 [thread overview]
Message-ID: <sashiko-outbox-251888@kernel.org> (raw)
In-Reply-To: <20261204-build-speedup-v7-4-19a89034d8d1@kernel.org>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] modpost: overlong module name triggers fatal() abort in
add_asm_this_module()
- [Low] cpupower: debug kernel Makefile clean target omits *.mod.S files
- [Low] modpost: buf_escaped() invokes buf_printf() per character
--
commit 7d565296db2d42a69262e66c5af6b91f8029de16
Author: Lorenzo Stoakes (ARM) <ljs@kernel.org>
modpost: emit module descriptors as assembly
This commit changes modpost to emit <module>.mod.S assembly files instead of
<module>.mod.c files, deriving structure layouts from a new
scripts/mod/module-offsets.h header. It also updates Kbuild, .gitignore,
clean rules, and scripts/tags.sh for the new .mod.S files.
> diff --git a/Makefile b/Makefile
> index 809ae80d5d70a..b41f613e42e40 100644
> --- a/Makefile
> +++ b/Makefile
[ ... ]
> @@ -2259,7 +2259,7 @@ clean: $(clean-dirs)
> -o -name '*.dt.yaml' -o -name 'dtbs-list' \
> -o -name '*.dwo' -o -name '*.lst' \
> -o -name '*.su' -o -name '*.mod' \
> - -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
> + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' -o -name '*.mod.S' \
> -o -name '*.lex.c' -o -name '*.tab.[ch]' \
> -o -name '*.asn1.[ch]' \
> -o -name '*.symtypes' -o -name 'modules.order' \
[Severity: Low]
Should the clean target in tools/power/cpupower/debug/kernel/Makefile also
remove *.mod.S?
That Makefile builds an external module via Kbuild but runs its own rm
command on clean (deleting *.mod.c without *.mod.S), so make clean will
leave cpufreq-test_tsc.mod.S behind.
[ ... ]
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index b23b2bd727a81..7d908bfcd002b 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
[ ... ]
> +/* Append the body of an assembler string literal, escaped as needed. */
> +static void buf_escaped(struct buffer *buf, const char *str)
> {
> - struct buffer buf = { };
> - struct module_alias *alias, *next;
> - char fname[PATH_MAX];
> - int ret;
> + unsigned char chr;
>
> - add_header(&buf, mod);
> - add_exported_symbols(&buf, mod);
> - add_versions(&buf, mod);
> - add_extended_versions(&buf, mod);
> - add_depends(&buf, mod);
> + while ((chr = *str++)) {
> + if (chr == '"' || chr == '\\')
> + buf_printf(buf, "\\%c", chr);
> + else if (isprint(chr))
> + buf_printf(buf, "%c", chr);
> + else
> + buf_printf(buf, "\\%03o", chr);
> + }
> +}
[Severity: Low]
Can buf_escaped() batch contiguous printable runs with buf_write() instead
of calling buf_printf() per byte?
buf_printf() is a non-static variadic helper that runs vsnprintf() on every
call. Because add_asm_aliases(), add_asm_ksymtab(), and
add_asm_extended_versions() route every alias and symbol string through
buf_escaped(), an allmodconfig build incurs millions of single-byte calls.
[ ... ]
> +/* Zero fill up to the offset. */
> +static void asm_skip_to(struct buffer *buf, unsigned int *pos,
> + unsigned int offset)
> +{
> + if (offset < *pos)
> + fatal("__this_module field at offset %u overlaps the previous one\n",
> + offset);
> + if (offset > *pos)
> + buf_printf(buf, "\t.skip %u\n", offset - *pos);
> +
> + *pos = offset;
> +}
[ ... ]
> +/* Emit one field of __this_module, returning its size. */
> +static unsigned int add_asm_this_module_field(struct buffer *buf,
> + const struct this_module_field *field)
> +{
> + if (field->is_name) {
> + buf_printf(buf, "\t.ascii \"%s\"\n", field->value);
> + return strlen(field->value);
> + }
> +
> + buf_printf(buf, "\t" MOD_PTR_DIRECTIVE " %s\n", field->value);
> + return MOD_SIZEOF_LONG;
> +}
[Severity: Low]
Can an overlong module name abort modpost via fatal() in asm_skip_to()
instead of letting check_modname_len()'s mod_error() stay non-fatal?
When a module basename is too long, check_modname_len() records a non-fatal
mod_error() so modpost can report remaining diagnostics, but main() still
calls write_mod_S_file(). add_asm_this_module_field() emits the unbounded
name and returns its full strlen(), pushing pos past the next field offset.
asm_skip_to() then exits immediately with a misleading field-overlap fatal
error (and skips checking any later modules). Clamping or skipping the name
when it is >= MOD_NAME_LEN would preserve the non-fatal behavior.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-build-speedup-v7-0-19a89034d8d1@kernel.org?part=4
next prev parent reply other threads:[~2026-12-05 20:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 20:27 [PATCH v7 0/7] kbuild: significantly speed up kernel builds Lorenzo Stoakes (ARM)
2026-12-04 20:27 ` [PATCH v7 1/7] kbuild: calculate list, composite object state per object Lorenzo Stoakes (ARM)
2026-12-04 20:27 ` [PATCH v7 2/7] kbuild: implement and use depcheck to check dependency timestamps Lorenzo Stoakes (ARM)
2026-12-05 20:29 ` sashiko-bot
2026-12-04 20:27 ` [PATCH v7 3/7] modpost: cache section relocation mismatch state Lorenzo Stoakes (ARM)
2026-12-05 20:29 ` sashiko-bot
2026-12-04 20:27 ` [PATCH v7 4/7] modpost: emit module descriptors as assembly Lorenzo Stoakes (ARM)
2026-12-05 20:29 ` sashiko-bot [this message]
2026-12-04 20:27 ` [PATCH v7 5/7] kbuild: batch module finalisation Lorenzo Stoakes (ARM)
2026-12-04 20:27 ` [PATCH v7 6/7] rust: make exports.o depend on the headers generated for it Lorenzo Stoakes (ARM)
2026-12-04 20:27 ` [PATCH v7 7/7] kbuild: build rust crates in parallel with the rest of the build Lorenzo Stoakes (ARM)
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-251888@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.