Re: [PATCH v2] seq_buf: always inline seq_buf_terminate() and the helpers around it

From: Nathan Chancellor

Date: Mon Nov 16 2026 - 13:57:01 EST


On Sun, Nov 15, 2026 at 09:20:04PM -0500, Sasha Levin wrote:
> Commit 7b8cd26b6aab8 ("seq_buf: Mark a seq_buf overflowed when terminating
> it loses a byte") made __seq_buf_terminate() bigger, and clang no longer
> inlines seq_buf_terminate() into its two callers in
> kernel/trace/trace_events.c. Both pass bootup_event_seq, which is
> __initdata, so the out-of-line copy sits in .text with that address in it
> and modpost warns:
>
> WARNING: modpost: vmlinux: section mismatch in reference: seq_buf_terminate+0x12 (section: .text) -> bootup_event_seq (section: .init.data)
>
> Both callers are __init, so nothing uses the buffer after it is freed.
> But the warning shows up in allmodconfig builds, and it is an error with
> CONFIG_SECTION_MISMATCH_WARN_ONLY=n.
>
> Always inlining only seq_buf_terminate() and __seq_buf_terminate() moves
> the problem: clang then leaves seq_buf_set_overflow() out of line with the
> same address in it. So mark every inline helper that trace_events.c
> reaches with bootup_event_seq __always_inline: seq_buf_terminate(),
> __seq_buf_terminate(), seq_buf_set_overflow(), seq_buf_buffer_left(),
> seq_buf_has_overflowed() and seq_buf_used().
>
> Fixes: 7b8cd26b6aab8 ("seq_buf: Mark a seq_buf overflowed when terminating it loses a byte")
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-kbuild-all/202611110802.zPIiPSnJ-lkp@xxxxxxxxx/
> Closes: https://lore.kernel.org/oe-kbuild-all/202611120138.Fwm5Ljmj-lkp@xxxxxxxxx/
> Closes: https://lore.kernel.org/oe-kbuild-all/202611122226.vTBpAmtr-lkp@xxxxxxxxx/
> Closes: https://lore.kernel.org/oe-kbuild-all/202611122323.IvGv8FYK-lkp@xxxxxxxxx/
> Suggested-by: Nathan Chancellor <nathan@xxxxxxxxxx>
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

Tested-by: Nathan Chancellor <nathan@xxxxxxxxxx> # build

--
Cheers,
Nathan