From: Petr Mladek <pmladek@suse.com>
To: Tamir Duberstein <tamird@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
kernel test robot <lkp@intel.com>
Subject: [PATCH v2] printf: Compile the kunit test with DISABLE_BRANCH_PROFILING
Date: Wed, 8 Apr 2026 14:28:19 +0200 [thread overview]
Message-ID: <adZJ41Cdvfv3-dWJ@pathway.suse.cz> (raw)
In-Reply-To: <CAJ-ks9ni9bth243ciTynDXGWG20sSbz52jSYHPsiVdxixkncPQ@mail.gmail.com>
Old GCC can miscompile printf_kunit's errptr() test when branch
profiling is enabled. BUILD_BUG_ON(IS_ERR(PTR)) is a constant false
expression, but CONFIG_TRACE_BRANCH_PROFILING and
CONFIG_PROFILE_ALL_BRANCHES make the IS_ERR() path side-effectful.
GCC's IPA splitter can then outline the cold assert arm into
errptr.part.* and leave that clone with an unconditional
__compiletime_assert_*() call, causing a false build failure.
This started showing up after test_hashed() became a macro and moved its
local buffer into errptr(), which changed GCC's inlining and splitting
decisions enough to expose the compiler bug.
Workaround the problem by disabling the branch profiling for
printf_kunit.o. It is a straightforward and acceptable solution.
Fixes: 9bfa52dac27a ("printf: convert test_hashed into macro")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202604030636.NqjaJvYp-lkp@intel.com/
Cc: stable@vger.kernel.org
Signed-off-by: Petr Mladek <pmladek@suse.com>
---
Changes against v1:
+ Disable the branch profiling for the whole printf_kunit.o
instead of using "noinline".
lib/tests/Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/tests/Makefile b/lib/tests/Makefile
index 05f74edbc62b..fbb2aad26994 100644
--- a/lib/tests/Makefile
+++ b/lib/tests/Makefile
@@ -40,6 +40,7 @@ obj-$(CONFIG_MEMCPY_KUNIT_TEST) += memcpy_kunit.o
obj-$(CONFIG_MIN_HEAP_KUNIT_TEST) += min_heap_kunit.o
CFLAGS_overflow_kunit.o = $(call cc-disable-warning, tautological-constant-out-of-range-compare)
obj-$(CONFIG_OVERFLOW_KUNIT_TEST) += overflow_kunit.o
+CFLAGS_printf_kunit.o += -DDISABLE_BRANCH_PROFILING
obj-$(CONFIG_PRINTF_KUNIT_TEST) += printf_kunit.o
obj-$(CONFIG_RANDSTRUCT_KUNIT_TEST) += randstruct_kunit.o
obj-$(CONFIG_SCANF_KUNIT_TEST) += scanf_kunit.o
--
2.53.0
next prev parent reply other threads:[~2026-04-08 12:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-05 17:31 [PATCH] printf: mark errptr() noinline Tamir Duberstein
2026-04-05 18:17 ` Greg KH
2026-04-06 15:15 ` Steven Rostedt
2026-04-06 15:21 ` Tamir Duberstein
2026-04-06 16:32 ` Steven Rostedt
2026-04-07 11:27 ` Petr Mladek
2026-04-07 13:34 ` Tamir Duberstein
2026-04-08 7:16 ` Petr Mladek
2026-04-08 10:18 ` Tamir Duberstein
2026-04-08 12:28 ` Petr Mladek [this message]
2026-04-08 12:42 ` [PATCH v2] printf: Compile the kunit test with DISABLE_BRANCH_PROFILING Tamir Duberstein
2026-04-07 15:08 ` [PATCH] printf: mark errptr() noinline David Laight
2026-04-08 7:24 ` Petr Mladek
2026-04-08 9:04 ` David Laight
2026-04-08 11:29 ` Andy Shevchenko
2026-04-08 12:12 ` David Laight
2026-04-06 16:40 ` Tamir Duberstein
2026-04-07 10:31 ` David Laight
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=adZJ41Cdvfv3-dWJ@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=lkp@intel.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=stable@vger.kernel.org \
--cc=tamird@kernel.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