mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Arnd Bergmann <arnd@kernel.org>,
	Kees Cook <kees@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	Alexei Starovoitov <ast@kernel.org>,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] seq_buf: avoid clang section mismatch from seq_buf_terminate optimization
Date: Tue, 1 Dec 2026 17:17:53 -0500	[thread overview]
Message-ID: <20261201171753.575cd2ee@gandalf.local.home> (raw)
In-Reply-To: <CAKwvOd=iZDq83GPddPLQSf6nxOaDORnAtrkxzn-BA_Nyv-3S-Q@mail.gmail.com>

On Tue, 1 Dec 2026 14:05:00 -0800
Nick Desaulniers <ndesaulniers@google.com> wrote:

> On Tue, Dec 1, 2026 at 1:54 PM Arnd Bergmann <arnd@arndb.de> wrote:
> >
> > On Tue, Dec 1, 2026, at 16:13, Steven Rostedt wrote:  
> > > On Tue,  1 Dec 2026 10:06:16 +0100 Arnd Bergmann <arnd@kernel.org> 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")

My question is, if this wasn't an inline to begin with and was just a
static function in that file, would it still warn?

What exactly did the kernel do wrong?

If we had:

static void seq_buf_set_overflow(struct seq_buf *s)
{
	if (s->len < s->size)
		memset(s->buffer + s->len, 0, s->size - s->len);

	s->len = s->size + 1;
}

static struct seq_buf bootup_event_seq __initdata = {
	.buffer = bootup_event_buf,
	.size = sizeof(bootup_event_buf),
};

static __init int event_trace_enable(void)
{
[..]
	seq_buf_terminate(&bootup_event_seq);
[..]
}

Is that a legitimate section mismatch?

I'm OK if we take this patch to convert to always_inline, but I do not see
it as a kernel fix but simply a workaround to the section matching issue,
as it appears to be as side effect of optimizations and nothing more.

-- Steve

> 
> > > 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).


      reply	other threads:[~2026-12-01 22:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  9:06 Arnd Bergmann
2026-12-01 15:13 ` Steven Rostedt
2026-12-01 21:53   ` Arnd Bergmann
2026-12-01 22:05     ` Nick Desaulniers
2026-12-01 22:17       ` Steven Rostedt [this message]

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=20261201171753.575cd2ee@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=ast@kernel.org \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=rdunlap@infradead.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®