From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Kees Cook <kees@kernel.org>
Cc: "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>,
"Masahiro Yamada" <masahiroy@kernel.org>,
"Alexey Gladkov" <legion@kernel.org>,
"Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Arnd Bergmann" <arnd@arndb.de>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Will Deacon" <will@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Ard Biesheuvel" <ardb@kernel.org>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"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>,
"Jonathan Corbet" <corbet@lwn.net>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, linux-riscv@lists.infradead.org,
linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-efi@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-doc@vger.kernel.org, "Jens Axboe" <axboe@kernel.dk>,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2 17/21] objtool: decode instructions and resolve branch targets in parallel
Date: Tue, 15 Sep 2026 11:09:25 +0100 [thread overview]
Message-ID: <aqkR9Xqu-0Tem1zm@gremlin> (raw)
In-Reply-To: <202609141112.F8983EE9C@keescook>
On Mon, Sep 14, 2026 at 11:20:37AM -0700, Kees Cook wrote:
> On Mon, Sep 14, 2026 at 10:22:16AM +0100, Lorenzo Stoakes (ARM) wrote:
> > Threads are only created for objects with 8 MiB or more of text, meaning
> > that runs involving smaller objects remain unaffected.
> > [...]
> > objtool on vmlinux.o is on the serial tail of every build that links
> > vmlinux, no-op builds are unchanged.
>
> This isn't limited to vmlinux.o, though? With CONFIG_X86_KERNEL_IBT
> (default y on x86_64), delay-objtool is set in scripts/Makefile.lib, and
> objtool then runs on every multi-object module, in the middle of the
> parallel part of the build. In an x86_64 allmodconfig build here,
> amdgpu.o has 46.2 MiB of executable text and i915.o has 10.2 MiB, so
> each of those objtool runs gets 16 threads on top of the -jN jobs that
> are already running.
Ack, will fix in v3 to limit to only the --link run without --module, which
is how vmlinux.o is processed, leaves modules as they are.
>
> Any parallelism added need to be handled by the make jobserver, not
> hard-coded anyway.
I'm not sure that really gains us anything - at the point of doing the
vmlinux.o processing (which with the above change is all that is being done
now) everything's idle so the jobserver would just hand over the same 16
threads.
It'd need quite a bit of work to interact with it too with added complexity
+ some overhead so would have to check impact on perf here.
You did complain about added complexity also ;) if you insist I can try.
>
> > [...]
> > +/* Only an object this large, e.g. vmlinux.o, is decoded on several threads. */
> > +#define DECODE_THREADED_MIN_TEXT SZ_8M
> > +/* Only decoding and the branch passes are threaded, so more gains nothing. */
> > +#define DECODE_MAX_THREADS 16
> > +#define DECODE_RANGES_PER_THREAD 4
>
> I just don't think a size-based approach is going to work. And any max
> parallelism needs a rationale.
A rationale was provided:
Threading is limited to decoding and the jump pass, so the gain
flattens out at 16 threads and any further threads were found to
only add overhead.
When performing an allmodconfig build, the clang invocation of
objtool when processing vmlinux.o took 5.93s on 1 thread, 4.56s on
8, 4.51s on 16 and 4.63s on 128.
Let me know what you feel was missing there? These things inevitably have
to be somewhat heuristic.
The size threshold is about paying for too many threads for no real gain,
and now (for v3) the code is limited to a --link operation only, that'll
only really stop a tinyconfig vmlinux.o :)
>
> > +static unsigned int decode_threads(unsigned long text_size)
> > +{
> > + const long nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
> > +
> > + if (text_size < DECODE_THREADED_MIN_TEXT || nr_cpus < 2)
> > + return 1;
> > +
> > + return min_t(unsigned int, nr_cpus, DECODE_MAX_THREADS);
> > +}
>
> No, anything using _SC_NPROCESSORS_ONLN internally is wrong, whether its
> pigz or objtool.
Why? We shouldn't cap a 4 CPU box to 4 CPUs?
The idea is that the empirically obtained 16 core limit should naturally be
capped to the number of CPUs.
I guess in a world where make hands jobs off this could be dropped, though,
if the complexity there seems worthwhile.
>
> > [...]
> > +static int add_jump_destinations(struct objtool_file *file)
> > +{
> > + return run_insn_ranges(file, add_jump_destinations_range);
> > +}
>
> I haven't examined this myself yet, but my LLM doesn't like this,
> saying:
>
> For an internal sibling call, add_jump_destination() calls
> add_call_dest(file, insn, dest_sym, true), and add_call_dest() calls
> annotate_call_site(), which for --hack-noinstr profiling calls, and for
> __fentry__ calls with --mcount --mnop, does set_reloc_type() and
> elf_write_insn() on file->elf. The per-range shadow gives each thread
> its own lists, but the struct elf is shared, and both helpers write to
> the section and mark it changed without any locking.
> add_call_destinations() is kept serial because "annotating a call site
> rewrites instructions the dead end walks read", so it looks like this
> path needs the same care: a lock, or deferring those writes until the
> threads have been joined. This is from reading the code; I haven't hit
> a failure. Was the thread sanitizer run mentioned in the cover letter
> done with those objtool options enabled?
>
> So, take it with a grain of salt. ;)
I mean sashiko is hallucinating at a rate >50% on this series, so pinches
of salt all round :) I do think frontier models with a good amount of
checking + e.g. Chris Mason's review-prompts are helpful to rein in stuff.
Anyway I had mine check it ;) and I also have a beefy threadripper sitting
around for bounding reality on this stuff and it all came back clean:
Those writes go to the thread's own instruction bytes and its own
relocation, the only shared state touched is the section and elf
"changed" flags, which every writer sets to true, and the mcount
case for a sibling call is a warning path. The v2 sanitizer run
used the gcc allmodconfig options, which lack
--mcount/--mnop/--cfi/--fineibt, so I reran it on the clang
allmodconfig vmlinux.o with its full option set: zero reports, the
jump pass included.
>
> -Kees
>
> --
> Kees Cook
--
Cheers, Lorenzo
next prev parent reply other threads:[~2026-09-15 10:09 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 9:21 [PATCH v2 00/21] kbuild: significantly speed up kernel builds Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 01/21] kbuild: do not allocate .modinfo in vmlinux Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 02/21] kallsyms: index symbols by token to speed up table compression Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 03/21] kallsyms: output binary data to speed output and kallsyms assembly Lorenzo Stoakes (ARM)
2026-09-14 20:16 ` Markus Elfring
2026-09-14 21:44 ` David Laight
2026-09-15 7:10 ` [v2 " Markus Elfring
2026-09-14 9:22 ` [PATCH v2 04/21] kbuild: do not sort nm output where the order is irrelevant Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 05/21] kbuild: only emit vmlinux relocations when required Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 06/21] elf-parse: add section flags, symbol binding and a read-only mapping Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 07/21] kallsyms: reimplement mksysmap in C Lorenzo Stoakes (ARM)
2026-09-14 16:33 ` Markus Elfring
2026-09-14 16:54 ` Markus Elfring
2026-09-14 17:01 ` Markus Elfring
2026-09-14 9:22 ` [PATCH v2 08/21] kbuild: cache list, composite object state per object Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 09/21] kbuild: implement and use depcheck to check dependency timestamps Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 10/21] kbuild: move the toolchain checks into init/Kconfig.toolchain Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 11/21] kbuild: avoid re-running compiler and linker probes Lorenzo Stoakes (ARM)
2026-09-14 15:02 ` John Stoffel
2026-09-14 15:24 ` Lorenzo Stoakes (ARM)
2026-09-15 11:01 ` Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 12/21] modpost: cache section relocation mismatch state Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 13/21] modpost: emit module descriptors as assembly Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 14/21] kbuild: batch module finalisation Lorenzo Stoakes (ARM)
2026-09-14 18:00 ` Kees Cook
2026-09-15 10:44 ` Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 15/21] objtool: cache relocations, do less work Lorenzo Stoakes (ARM)
2026-09-14 19:44 ` Josh Poimboeuf
2026-09-14 20:06 ` Linus Torvalds
2026-09-14 22:23 ` Josh Poimboeuf
2026-09-14 22:30 ` Linus Torvalds
2026-09-15 12:24 ` Lorenzo Stoakes (ARM)
2026-09-15 12:19 ` Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 16/21] objtool: size the instruction hash to the text Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 17/21] objtool: decode instructions and resolve branch targets in parallel Lorenzo Stoakes (ARM)
2026-09-14 18:20 ` Kees Cook
2026-09-15 10:09 ` Lorenzo Stoakes (ARM) [this message]
2026-09-15 11:29 ` David Laight
2026-09-14 9:22 ` [PATCH v2 18/21] kbuild: rust: optionally parallelise rustc front end Lorenzo Stoakes (ARM)
2026-09-14 18:32 ` Kees Cook
2026-09-15 11:09 ` Lorenzo Stoakes (ARM)
2026-09-15 11:16 ` Lorenzo Stoakes (ARM)
2026-09-15 6:32 ` Miguel Ojeda
2026-09-15 11:15 ` Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 19/21] rust: make exports.o depend on the headers generated for it Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 20/21] kbuild: build rust crates in parallel with the rest of the build Lorenzo Stoakes (ARM)
2026-09-14 18:37 ` Kees Cook
2026-09-15 11:58 ` Lorenzo Stoakes (ARM)
2026-09-14 9:22 ` [PATCH v2 21/21] kbuild: use pigz for gzip compression if available Lorenzo Stoakes (ARM)
2026-09-14 16:39 ` Kees Cook
2026-09-14 16:49 ` H. Peter Anvin
2026-09-14 17:50 ` Kees Cook
2026-09-14 15:41 ` [PATCH v2 00/21] kbuild: significantly speed up kernel builds Kees Cook
2026-09-14 15:53 ` Linus Torvalds
2026-09-15 8:53 ` Arnd Bergmann
2026-09-15 11:35 ` Lorenzo Stoakes (ARM)
2026-09-14 18:25 ` Lorenzo Stoakes (ARM)
2026-09-14 18:43 ` Kees Cook
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=aqkR9Xqu-0Tem1zm@gremlin \
--to=ljs@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=alex@ghiti.fr \
--cc=aliceryhl@google.com \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=axboe@kernel.dk \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dave.hansen@linux.intel.com \
--cc=gary@garyguo.net \
--cc=gustavoars@kernel.org \
--cc=hpa@zytor.com \
--cc=ilias.apalodimas@linaro.org \
--cc=jpoimboe@kernel.org \
--cc=justinstitt@google.com \
--cc=kees@kernel.org \
--cc=legion@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=llvm@lists.linux.dev \
--cc=lossin@kernel.org \
--cc=mark.rutland@arm.com \
--cc=masahiroy@kernel.org \
--cc=mingo@redhat.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nsc@kernel.org \
--cc=ojeda@kernel.org \
--cc=palmer@dabbelt.com \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tglx@kernel.org \
--cc=tmgross@umich.edu \
--cc=torvalds@linux-foundation.org \
--cc=will@kernel.org \
--cc=work@onurozkan.dev \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®