Re: [PATCH] seq_buf: avoid clang section mismatch from seq_buf_terminate optimization
From: Nick Desaulniers
Date: Tue Dec 01 2026 - 17:05:18 EST
On Tue, Dec 1, 2026 at 1:54 PM Arnd Bergmann <arnd@xxxxxxxx> wrote:
>
> On Tue, Dec 1, 2026, at 16:13, Steven Rostedt wrote:
> > On Tue, 1 Dec 2026 10:06:16 +0100 Arnd Bergmann <arnd@xxxxxxxxxx> wrote:
> >>
> >> I'm unsure whether this should be considered a bug in clang or the
> >> kernel, or what the best workaround is. The two options I considered
> >> are:
> >
> > It's definitely a bug in clang. If it created a specialized version of a
I saw this thread earlier and rolled my eyes. This wasn't a compiler
bug back during the countless other modpost warnings we've fixed in
kernel sources. It's still not.
commit 2780860eddec ("include/linux/list.h: mark list_add and
__list_add as __always_inline")
commit f9d2ee3f51d6 ("riscv: Always inline bitops")
commit d5fd042bf4cf ("x86/resctrl: Annotate get_mem_config() functions
as __init")
commit 1ec2362084a0 ("ARM: imx: Annotate imx7d_enet_init() as __init")
> > function and that version is now causing section mismatches, that's a bug
> > in the compiler. The kernel did nothing wrong.
>
> Not sure I understand, do you mean clang should skip the FunctionSpecialization
> in interprocedural constant propagation altogether when building the kernel,
> or do you think we should teach clang about the kernel's concept of what
> functions are allowed to reference .initdata?
>
> Is the clang behavior fundamentally different from gcc here? It seems to
> me that gcc just didn't hit this issue because unlike clang it does
> inline across sections.
Asserting "clang does not inline across sections" is a _false_
assertion: https://godbolt.org/z/7TTnxo9Wb (i.e. observe baz jmp'ing
to bar because foo was inlined, despite being in .woof rather than
.text).
--
Thanks,
~Nick Desaulniers