mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] bug: fix warning suppressions with kunit built as module
@ 2026-07-08  9:54 Bartosz Golaszewski
  2026-07-08 10:00 ` Albert Esteve
  2026-07-08 10:03 ` David Gow
  0 siblings, 2 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-07-08  9:54 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 due to it using a plain #ifdef,
rendering warning suppressions broken for kunit build as loadable module.

kunit_is_suppressed_warning() already has a stub for when kunit is
disabled so drop that guard entirely.

Suggested-by: Albert Esteve <aesteve@redhat.com>
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>
---
Changes in v2:
- drop the guard entirely instead of switching to IS_ENABLED()

 lib/bug.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lib/bug.c b/lib/bug.c
index 292420f45811..7c1c2c27f58e 100644
--- a/lib/bug.c
+++ b/lib/bug.c
@@ -219,14 +219,12 @@ 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
 	/*
 	 * Before the once logic so suppressed warnings do not consume
 	 * the single-fire budget of WARN_ON_ONCE().
 	 */
 	if (warning && kunit_is_suppressed_warning(true))
 		return BUG_TRAP_TYPE_WARN;
-#endif
 
 	disable_trace_on_warning();
 
-- 
2.47.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] bug: fix warning suppressions with kunit built as module
  2026-07-08  9:54 [PATCH v2] bug: fix warning suppressions with kunit built as module Bartosz Golaszewski
@ 2026-07-08 10:00 ` Albert Esteve
  2026-07-08 10:03 ` David Gow
  1 sibling, 0 replies; 5+ messages in thread
From: Albert Esteve @ 2026-07-08 10:00 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 Wed, Jul 8, 2026 at 11:55 AM 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 due to it using a plain #ifdef,
> rendering warning suppressions broken for kunit build as loadable module.
>
> kunit_is_suppressed_warning() already has a stub for when kunit is
> disabled so drop that guard entirely.
>
> Suggested-by: Albert Esteve <aesteve@redhat.com>
> 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>

Reviewed-by: Albert Esteve <aesteve@redhat.com>

Thanks!


> ---
> Changes in v2:
> - drop the guard entirely instead of switching to IS_ENABLED()
>
>  lib/bug.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/lib/bug.c b/lib/bug.c
> index 292420f45811..7c1c2c27f58e 100644
> --- a/lib/bug.c
> +++ b/lib/bug.c
> @@ -219,14 +219,12 @@ 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
>         /*
>          * Before the once logic so suppressed warnings do not consume
>          * the single-fire budget of WARN_ON_ONCE().
>          */
>         if (warning && kunit_is_suppressed_warning(true))
>                 return BUG_TRAP_TYPE_WARN;
> -#endif
>
>         disable_trace_on_warning();
>
> --
> 2.47.3
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] bug: fix warning suppressions with kunit built as module
  2026-07-08  9:54 [PATCH v2] bug: fix warning suppressions with kunit built as module Bartosz Golaszewski
  2026-07-08 10:00 ` Albert Esteve
@ 2026-07-08 10:03 ` David Gow
  2026-07-08 10:07   ` Bartosz Golaszewski
  1 sibling, 1 reply; 5+ messages in thread
From: David Gow @ 2026-07-08 10:03 UTC (permalink / raw)
  To: Bartosz Golaszewski, Shuah Khan, Guenter Roeck, Albert Esteve,
	Kees Cook, Alessandro Carminati, Andrew Morton, Brendan Higgins,
	Rae Moar
  Cc: linux-kernel, linux-kselftest, brgl, stable

Le 08/07/2026 à 5:54 PM, Bartosz Golaszewski a écrit :
> CONFIG_KUNIT is a tristate symbol but the warning suppression code in
> lib/bug.c is only built if it's built-in due to it using a plain #ifdef,
> rendering warning suppressions broken for kunit build as loadable module.
> 
> kunit_is_suppressed_warning() already has a stub for when kunit is
> disabled so drop that guard entirely.
> 
> Suggested-by: Albert Esteve <aesteve@redhat.com>
> 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>
> ---
> Changes in v2:
> - drop the guard entirely instead of switching to IS_ENABLED()
> 

Thanks very much. Works well here.

Reviewed-by: David Gow <david@davidgow.net>

Happy to take this via kselftest/kunit, but if you'd prefer it go in via
mm-nonmm, that's fine too.

Cheers,
-- David

>  lib/bug.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/lib/bug.c b/lib/bug.c
> index 292420f45811..7c1c2c27f58e 100644
> --- a/lib/bug.c
> +++ b/lib/bug.c
> @@ -219,14 +219,12 @@ 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
>  	/*
>  	 * Before the once logic so suppressed warnings do not consume
>  	 * the single-fire budget of WARN_ON_ONCE().
>  	 */
>  	if (warning && kunit_is_suppressed_warning(true))
>  		return BUG_TRAP_TYPE_WARN;
> -#endif
>  
>  	disable_trace_on_warning();
>  


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] bug: fix warning suppressions with kunit built as module
  2026-07-08 10:03 ` David Gow
@ 2026-07-08 10:07   ` Bartosz Golaszewski
  2026-07-08 10:08     ` Bartosz Golaszewski
  0 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-07-08 10:07 UTC (permalink / raw)
  To: David Gow
  Cc: linux-kernel, linux-kselftest, brgl, stable, Bartosz Golaszewski,
	Shuah Khan, Guenter Roeck, Albert Esteve, Kees Cook,
	Alessandro Carminati, Andrew Morton, Brendan Higgins, Rae Moar

On Wed, 8 Jul 2026 12:03:31 +0200, David Gow <david@davidgow.net> said:
> Le 08/07/2026 à 5:54 PM, Bartosz Golaszewski a écrit :
>> CONFIG_KUNIT is a tristate symbol but the warning suppression code in
>> lib/bug.c is only built if it's built-in due to it using a plain #ifdef,
>> rendering warning suppressions broken for kunit build as loadable module.
>>
>> kunit_is_suppressed_warning() already has a stub for when kunit is
>> disabled so drop that guard entirely.
>>
>> Suggested-by: Albert Esteve <aesteve@redhat.com>
>> 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>
>> ---
>> Changes in v2:
>> - drop the guard entirely instead of switching to IS_ENABLED()
>>
>
> Thanks very much. Works well here.
>
> Reviewed-by: David Gow <david@davidgow.net>
>
> Happy to take this via kselftest/kunit, but if you'd prefer it go in via
> mm-nonmm, that's fine too.
>

I sent a v2 as suggested by Albert. I don't have a strong opinion on which
one should go upstream.

Bart

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] bug: fix warning suppressions with kunit built as module
  2026-07-08 10:07   ` Bartosz Golaszewski
@ 2026-07-08 10:08     ` Bartosz Golaszewski
  0 siblings, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2026-07-08 10:08 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: linux-kernel, linux-kselftest, stable, Bartosz Golaszewski,
	Shuah Khan, Guenter Roeck, Albert Esteve, Kees Cook,
	Alessandro Carminati, Andrew Morton, Brendan Higgins, Rae Moar,
	David Gow

On Wed, 8 Jul 2026 12:07:40 +0200, Bartosz Golaszewski <brgl@kernel.org> said:
> On Wed, 8 Jul 2026 12:03:31 +0200, David Gow <david@davidgow.net> said:
>> Le 08/07/2026 à 5:54 PM, Bartosz Golaszewski a écrit :
>>> CONFIG_KUNIT is a tristate symbol but the warning suppression code in
>>> lib/bug.c is only built if it's built-in due to it using a plain #ifdef,
>>> rendering warning suppressions broken for kunit build as loadable module.
>>>
>>> kunit_is_suppressed_warning() already has a stub for when kunit is
>>> disabled so drop that guard entirely.
>>>
>>> Suggested-by: Albert Esteve <aesteve@redhat.com>
>>> 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>
>>> ---
>>> Changes in v2:
>>> - drop the guard entirely instead of switching to IS_ENABLED()
>>>
>>
>> Thanks very much. Works well here.
>>
>> Reviewed-by: David Gow <david@davidgow.net>
>>
>> Happy to take this via kselftest/kunit, but if you'd prefer it go in via
>> mm-nonmm, that's fine too.
>>
>
> I sent a v2 as suggested by Albert. I don't have a strong opinion on which
> one should go upstream.
>

Ah, nevermind that comment, I thought I was responding under v1.

Bart

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-08 10:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-08  9:54 [PATCH v2] bug: fix warning suppressions with kunit built as module Bartosz Golaszewski
2026-07-08 10:00 ` Albert Esteve
2026-07-08 10:03 ` David Gow
2026-07-08 10:07   ` Bartosz Golaszewski
2026-07-08 10:08     ` Bartosz Golaszewski

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®