* [PATCH] bug: fix warning suppressions with kunit built as module
@ 2026-07-07 12:58 Bartosz Golaszewski
2026-07-07 13:17 ` Albert Esteve
2026-07-08 13:34 ` Nico Pache
0 siblings, 2 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2026-07-07 12:58 UTC (permalink / raw)
To: Shuah Khan, Guenter Roeck, Albert Esteve, Kees Cook,
Alessandro Carminati, Andrew Morton, Brendan Higgins, David Gow,
Rae Moar
Cc: linux-kernel, linux-kselftest, brgl, Bartosz Golaszewski, stable
CONFIG_KUNIT is a tristate symbol but the warning suppression code in
lib/bug.c is only built if it's built-in. Use IS_ENABLE(CONFIG_KUNIT) to
enable it for a loadable kunit module as well. When using a plain #ifdef,
the suppressions only work if kunit is built-in.
Cc: stable@vger.kernel.org
Fixes: 85347718ab0d ("bug/kunit: Core support for suppressing warning backtraces")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
lib/bug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/bug.c b/lib/bug.c
index 292420f45811..b9820a0226f5 100644
--- a/lib/bug.c
+++ b/lib/bug.c
@@ -219,7 +219,7 @@ static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long buga
no_cut = bug->flags & BUGFLAG_NO_CUT_HERE;
has_args = bug->flags & BUGFLAG_ARGS;
-#ifdef CONFIG_KUNIT
+#if IS_ENABLED(CONFIG_KUNIT)
/*
* Before the once logic so suppressed warnings do not consume
* the single-fire budget of WARN_ON_ONCE().
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] bug: fix warning suppressions with kunit built as module
2026-07-07 12:58 [PATCH] bug: fix warning suppressions with kunit built as module Bartosz Golaszewski
@ 2026-07-07 13:17 ` Albert Esteve
2026-07-08 13:34 ` Nico Pache
1 sibling, 0 replies; 3+ messages in thread
From: Albert Esteve @ 2026-07-07 13:17 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Shuah Khan, Guenter Roeck, Kees Cook, Alessandro Carminati,
Andrew Morton, Brendan Higgins, David Gow, Rae Moar,
linux-kernel, linux-kselftest, brgl, stable
On Tue, Jul 7, 2026 at 2:58 PM Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:
>
> CONFIG_KUNIT is a tristate symbol but the warning suppression code in
> lib/bug.c is only built if it's built-in. Use IS_ENABLE(CONFIG_KUNIT) to
> enable it for a loadable kunit module as well. When using a plain #ifdef,
> the suppressions only work if kunit is built-in.
>
> Cc: stable@vger.kernel.org
> Fixes: 85347718ab0d ("bug/kunit: Core support for suppressing warning backtraces")
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
> lib/bug.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/bug.c b/lib/bug.c
> index 292420f45811..b9820a0226f5 100644
> --- a/lib/bug.c
> +++ b/lib/bug.c
> @@ -219,7 +219,7 @@ static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long buga
> no_cut = bug->flags & BUGFLAG_NO_CUT_HERE;
> has_args = bug->flags & BUGFLAG_ARGS;
>
> -#ifdef CONFIG_KUNIT
> +#if IS_ENABLED(CONFIG_KUNIT)
Hello Bartosz,
Thanks for the fix! While it is correct, I think we could just drop
the guard completely. kunit_is_suppressed_warning() already has a
correct stub in the #else branch of include/kunit/test-bug.h when
CONFIG_KUNIT is not enabled:
static inline bool kunit_is_suppressed_warning(bool count) { return false; }
With it, the check in lib/bug.c is redundant.
BR,
Albert
> /*
> * Before the once logic so suppressed warnings do not consume
> * the single-fire budget of WARN_ON_ONCE().
> --
> 2.47.3
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] bug: fix warning suppressions with kunit built as module
2026-07-07 12:58 [PATCH] bug: fix warning suppressions with kunit built as module Bartosz Golaszewski
2026-07-07 13:17 ` Albert Esteve
@ 2026-07-08 13:34 ` Nico Pache
1 sibling, 0 replies; 3+ messages in thread
From: Nico Pache @ 2026-07-08 13:34 UTC (permalink / raw)
To: Bartosz Golaszewski, Shuah Khan, Guenter Roeck, Albert Esteve,
Kees Cook, Alessandro Carminati, Andrew Morton, Brendan Higgins,
David Gow, Rae Moar
Cc: linux-kernel, linux-kselftest, brgl, stable
On 7/7/26 6:58 AM, Bartosz Golaszewski wrote:
> CONFIG_KUNIT is a tristate symbol but the warning suppression code in
> lib/bug.c is only built if it's built-in. Use IS_ENABLE(CONFIG_KUNIT) to
> enable it for a loadable kunit module as well. When using a plain #ifdef,
> the suppressions only work if kunit is built-in.
>
> Cc: stable@vger.kernel.org
> Fixes: 85347718ab0d ("bug/kunit: Core support for suppressing warning backtraces")
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
I ran into the same issue and found the following fix also resolved the issue.
Tested-by: Nico Pache <npache@redhat.com>
Acked-by: Nico Pache <npache@redhat.com>
> ---
> lib/bug.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/bug.c b/lib/bug.c
> index 292420f45811..b9820a0226f5 100644
> --- a/lib/bug.c
> +++ b/lib/bug.c
> @@ -219,7 +219,7 @@ static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long buga
> no_cut = bug->flags & BUGFLAG_NO_CUT_HERE;
> has_args = bug->flags & BUGFLAG_ARGS;
>
> -#ifdef CONFIG_KUNIT
> +#if IS_ENABLED(CONFIG_KUNIT)
> /*
> * Before the once logic so suppressed warnings do not consume
> * the single-fire budget of WARN_ON_ONCE().
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-08 13:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-07 12:58 [PATCH] bug: fix warning suppressions with kunit built as module Bartosz Golaszewski
2026-07-07 13:17 ` Albert Esteve
2026-07-08 13:34 ` Nico Pache
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®