From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796115994; b=stz1F0z8ab+6ocGQdvUSPN6a0Iygv0I91y+4BhBbsjpTSnbyPj06aLgHFBhade4a1Tiz KHYhe1bHx6SVq6cLS77tl2bfYRFaQK3WNeW+LzhoMvDAEN6xbI9dcgBtfOgYyVBBvjVHe HbsZmNFg+LLRjR6Nnaq6AUmlvvgkGmwRYDlBg9jvvJWq9+RTeMdaBIykX5vj0xtvOvgZl 87VJ5/J4L0Yi1genZcqfScM6zTobMHOlAXmLn4yYnUkZzFmKyj36L066fVScRCHksJE4h XXD+Yy4uY+gAfY0r3VZV4twfv5bOec5UpZXxtvlC1JedOJgigDVJf/JE0wTwsDup9kQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796115994; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Transfer-Encoding; bh=0jwNsdnsTJHchczxXPVu2iSH0lqk42fXdxo7jMIl5Z8=; b=gedZX9zz7wJxGXkMcbkshSvLDxA7dy/pmwCuKr14ZF14g4XKfT6IM+pz248SRWbmrH9I na56DcRJPy/eHY22nWDAVWmO7eLfnwPYTGa2CyxnRBYBSVKvrSIAw8LNWyXXbI5I2c/hk mXlCf6j+a119vCqHqUM6zgzZVVIj1b8+VGSa0ciMqwNvgeoDnvFnOgk+qM/oIiWDWo1km SSonM6oLwsk3nMwCDE+ANnPNCMHm0FDjX8McKrx58jfyahG4jx3CFzoiKSnNkus+fjnoT YL3Df+8gofwzwd+nG9vjPxdhawVE+8Aw2vgjuQUqsP8Ku5QkoMNg2cu1xRJFLmdZvfA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MpOduwSD; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 686EC606A31A; Tue, 1 Dec 2026 09:06:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=MpOduwSD Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E8381F00897; Tue, 1 Dec 2026 09:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796115994; bh=0jwNsdnsTJHchczxXPVu2iSH0lqk42fXdxo7jMIl5Z8=; h=From:To:Cc:Subject:Date; b=MpOduwSDjutoU1KfrTy0rETzbu0kUDdA88a3iyc5+fuxC0ttcEyrpCOgnJG0fBpzn fyhHsKgqPdAAC0PoCNrutcHQJzbjp1+iPFdRXimZdZ1v/xakH0zB4U7UKYs1ATU3m+ 3f+QN7TTr4B7OUzCTIAhRt7ZtrJl/2OkiJM3PmpSIVsCckFkXWZQZWSWunvfsXpVhd CQY9+hxAzmgj/Gdl9wIIh9yA6cleNf5LdrhnjVJwBvSfA5JQOBnPkQ0ZEM8dTDRhEz R7eZJuyxLoPDGtKBwdGC39LvuUlMXxJ4PXYDFHJrpFr0tNNUdPTVUOJ4NVNueqRA9I XbZVhmIbJEtjg== From: Arnd Bergmann To: Kees Cook , Nathan Chancellor , Steven Rostedt Cc: Arnd Bergmann , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Shevchenko , Randy Dunlap , Alexei Starovoitov , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] seq_buf: avoid clang section mismatch from seq_buf_terminate optimization Date: Tue, 1 Dec 2026 10:06:16 +0100 Message-ID: <20261201090627.699022-1-arnd@kernel.org> X-Mailer: git-send-email 2.53.0 X-Mailing-List: llvm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arnd Bergmann I observed clang-21 create a specialized version of seq_buf_terminate() that hardcodes the 'bootup_event_seq' argument since all callers pass the same one. Since seq_buf_terminate is not marked __init, it does not get inlined into the caller if that is __init, but the __initdata argument does get referenced from the specialized version, causing a section mismatch warning: WARNING: modpost: vmlinux: section mismatch in reference: __seq_buf_terminate+0x13 (section: .text) -> bootup_event_seq (section: .init.data) WARNING: modpost: vmlinux: section mismatch in reference: seq_buf_terminate+0xda (section: .text) -> bootup_event_seq (section: .init.data) ERROR: modpost: Section mismatches detected. Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them. 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: - mark bootup_event_seq as non-__initdata to avoid this one instance, slightly pessimizing this the runtime memory usage and possibly having the same situation elsewhere - mark all three functions in the call chain as __always_inline, forcing an inlining decision that the compiler would perhaps not make, but preventing other instances of this issue as well. This is the second option. Fixes: 7b8cd26b6aab ("seq_buf: Mark a seq_buf overflowed when terminating it loses a byte") Link: https://lore.kernel.org/all/20261118171346.FH6VoALE-lkp@intel.com/ Signed-off-by: Arnd Bergmann --- include/linux/seq_buf.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index 6b915c67d235..43bc067c82cf 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -74,7 +74,7 @@ seq_buf_has_overflowed(struct seq_buf *s) * seq_buf_str() terminates it, so clear whatever was not written: a writer * sets len to how much it filled, and anything past that was never adopted. */ -static inline void +static __always_inline void seq_buf_set_overflow(struct seq_buf *s) { if (s->len < s->size) @@ -134,7 +134,7 @@ static inline unsigned int seq_buf_used(struct seq_buf *s) * * Returns: the offset of the NUL. */ -static inline size_t __seq_buf_terminate(struct seq_buf *s) +static __always_inline size_t __seq_buf_terminate(struct seq_buf *s) { size_t end; @@ -240,7 +240,7 @@ static inline size_t seq_buf_strlen(struct seq_buf *s) * After this function is called, s->buffer is safe to use * in string operations. */ -static inline void seq_buf_terminate(struct seq_buf *s) +static __always_inline void seq_buf_terminate(struct seq_buf *s) { if (s->size == 0) return; -- 2.53.0