From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=216.40.44.16 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796163480; b=LA3oFNapMQSfsFrN7wvlN1JTAecV1EWj0yvMQifnqrrK83L9P78jbFSNKVsXmkDFQwY7 x7pqLuJZQT2xe2xjEb8Ah+eUuUTJ68gHLAQxnojV1MNWPQLW2Q2DhzLwLSprGMSXzdVRK ZmJm6EDM0VaiWuUirdp45qVqwsVn1uuD++KibuPi1tLKrxGnRPEAz4uJnOGR0pOcvFCp+ atVJp6PiXEnFP9+UQYX5dgyBxvVsb7LdvtTe0GuDMjlxf4s90AfLOJJhKK6h/IXto539T PnVw0wm0WCdELFtMqy31ORuu0a7bKkA0IqG9X6cZiJE98iF5ZHLvqcrGymRotn3e+aw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796163480; h=DMARC-Filter:Received:Received:Date:From:To:Cc:Subject:Message-ID: In-Reply-To:References:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding:X-Stat-Signature:X-Spam-Status: X-Rspamd-Server:X-Rspamd-Queue-Id:X-Session-Marker:X-Session-ID: DKIM-Signature:X-HE-Tag:X-HE-Meta; bh=KuLUpUfWzfN1TCERRpQjxldciBjqMqDdDo3XHIvIA14=; b=Vkcw2RmEPVtwIMBhQGgoHC3rdqU4q8KEFxDZAW3wL4EdeTAM88OViFufMKA2auKCI7PR Gee1U36DOvWYjIxBUGwdMAo2fPnw0e6574BRThZ1IliFmTRZdqNypB2L4iNdACpsAV8TX QorcAKmzbmRVhdFG+ct8ySc/sNZS6XfK9107nbAIyGKI9Yln/NrH9F/kgykPH+VTcJHwx IY1tbwlP1JgLQ+y9SJKIU4LkxzxMy/9H9ePaG0F45BxLJ4RDHKvMOVuOQyxwDRbNPE5lW 2TgxxWwtiPCPJ9VzhJK+t5BhqIdb+z38JfkNueuXi57b1OgOXM2k/6IW0+v5zdBdP2A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=goodmis.org; spf=pass smtp.mailfrom=goodmis.org; dkim=pass header.d=goodmis.org header.i=@goodmis.org header.a=rsa-sha256 header.s=dkim1 header.b="iBKwKU/4"; arc=none smtp.remote-ip=216.40.44.16 Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ADBC9606A32C for ; Tue, 1 Dec 2026 22:17:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ADBC9606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=goodmis.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=goodmis.org header.i=@goodmis.org header.a=rsa-sha256 header.s=dkim1 header.b=iBKwKU/4 Received: from omf20.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 822C1C10FF; Tue, 1 Dec 2026 22:17:57 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf20.hostedemail.com (Postfix) with ESMTPA id D934E20025; Tue, 1 Dec 2026 22:17:54 +0000 (UTC) Date: Tue, 1 Dec 2026 17:17:53 -0500 From: Steven Rostedt To: Nick Desaulniers Cc: Arnd Bergmann , Arnd Bergmann , Kees Cook , Nathan Chancellor , Bill Wendling , Justin Stitt , Andy Shevchenko , Randy Dunlap , Alexei Starovoitov , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH] seq_buf: avoid clang section mismatch from seq_buf_terminate optimization Message-ID: <20261201171753.575cd2ee@gandalf.local.home> In-Reply-To: References: <20261201090627.699022-1-arnd@kernel.org> <20261201101314.233335f6@gandalf.local.home> <23f85d0b-5d9e-4728-a969-5c083a1b33f2@app.fastmail.com> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Stat-Signature: qfw773q4y4kupfx4k68n87r5pkknwp7u X-Rspamd-Server: rspamout01 X-Rspamd-Queue-Id: D934E20025 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX1/q73lkIvkh+EAm5TcOWzz+CXP7l/hRnwg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=goodmis.org; h=date:from:to:cc:subject:message-id:in-reply-to:references:mime-version:content-type:content-transfer-encoding; s=dkim1; bh=KuLUpUfWzfN1TCERRpQjxldciBjqMqDdDo3XHIvIA14=; b=iBKwKU/4VkKQnhHb0cWuQ5HdEjfv+GZ4WtWq3oEUpG9bGfPaZsiRwY3+QYe3qge57b47StPJMDCEdvmFezB30Nwlo4NJ94mS5CMlooBOifYrvqnLv/m2BB+hr8ZArRUYXX3RQzvs8HkLOru1UuybD54CJrOiWfr6HX8qWG5YrQE= X-HE-Tag: 1796163474-880553 X-HE-Meta: U2FsdGVkX1+N3asQkB8/NXhDu+XkpMayPM6ydNxgVa1QZhhiigoCb+wCCZCuTTXOSREJpJY/TJ7zRrSEV9JY5XmxOMx0e5pZ5SyQNkeIgpZ8QZxEVUM3gzoW65xu8FvJ52UlSpQ3r6FB+f/bCt3fRD6V2xXRBiZE6aAN/i49ZJGjQSfzxjIBfvI8erkXfN5chaKOcn2TbwmketWAkSOMnCkQx3E87syP5oKHEi3R5c6/EoXrogdfZ0mD49L93sIQBCooy2fWjeXYvEn0C/axuJjhOP4AVIu7gZFMGCWnAhiNVUIc5b1FKTYQLLaRNESAtmDpETkttW52bfoRzY3l5+NuhFeS32YHZS/PFscHybzeslz9vW3+oRQT6iytjxyXNeCcaeUiZ/8DC+14GcWSD8cSsL9Ug/SIyfJCUUq0VEM= On Tue, 1 Dec 2026 14:05:00 -0800 Nick Desaulniers wrote: > On Tue, Dec 1, 2026 at 1:54=E2=80=AFPM Arnd Bergmann wrot= e: > > > > On Tue, Dec 1, 2026, at 16:13, Steven Rostedt wrote: =20 > > > On Tue, 1 Dec 2026 10:06:16 +0100 Arnd Bergmann wr= ote: =20 > > >> > > >> 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: =20 > > > > > > It's definitely a bug in clang. If it created a specialized version o= f a =20 >=20 > 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. >=20 > commit 2780860eddec ("include/linux/list.h: mark list_add and > __list_add as __always_inline") >=20 > commit f9d2ee3f51d6 ("riscv: Always inline bitops") >=20 > commit d5fd042bf4cf ("x86/resctrl: Annotate get_mem_config() functions > as __init") >=20 > 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 =3D s->size + 1; } static struct seq_buf bootup_event_seq __initdata =3D { .buffer =3D bootup_event_buf, .size =3D 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 >=20 > > > function and that version is now causing section mismatches, that's a= bug > > > in the compiler. The kernel did nothing wrong. =20 > > > > Not sure I understand, do you mean clang should skip the FunctionSpecia= lization > > in interprocedural constant propagation altogether when building the ke= rnel, > > 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. =20 >=20 > 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).