Skip to contentSkip to conversation

bug: fix warning suppressions with kunit built as module

PATCH Applied Bartosz Golaszewski 4 participants 5 messages Jul 8

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bug: fix warning suppressions with kunit built as module

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.

Fixes 85347718ab0d ("bug/kunit: Core support for suppressing warning backtraces")

---
Changes in v2:
- drop the guard entirely instead of switching to IS_ENABLED()

 lib/bug.c | 2 --
 1 file changed, 2 deletions(-)
lib/bug.c +0 -2
index 292420f45811..7c1c2c27f58e 100644
@@ -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();
 
Signature · 1 line
2.47.3
Reviewed-by on v2 1/1
#1 lore raw
Quoted 5 lines · Bartosz Golaszewski

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.

Quoted 7 lines

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

Fixes 85347718ab0d ("bug/kunit: Core support for suppressing warning backtraces")

Thanks!

Quoted 29 lines

---
Changes in v2:
- drop the guard entirely instead of switching to IS_ENABLED()

 lib/bug.c | 2 --
 1 file changed, 2 deletions(-)
lib/bug.c +0 -3
index 292420f45811..7c1c2c27f58e 100644
@@ -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

Reviewed-by on v2 1/1
#2 lore raw
In reply to Bartosz Golaszewski

Le 08/07/2026 à 5:54 PM, Bartosz Golaszewski a écrit :

Quoted 7 lines

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.

Quoted 8 lines
Fixes 85347718ab0d ("bug/kunit: Core support for suppressing warning backtraces")

---
Changes in v2:
- drop the guard entirely instead of switching to IS_ENABLED()

Thanks very much. Works well here.

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

Cheers,
-- David

Quoted 22 lines
 lib/bug.c | 2 --
 1 file changed, 2 deletions(-)
lib/bug.c +0 -2
index 292420f45811..7c1c2c27f58e 100644
@@ -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();
 
#3 lore raw
Quoted 17 lines · David Gow

Le 08/07/2026 à 5:54 PM, Bartosz Golaszewski a écrit :

Quoted 7 lines

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.

Quoted 8 lines
Fixes 85347718ab0d ("bug/kunit: Core support for suppressing warning backtraces")

---
Changes in v2:
- drop the guard entirely instead of switching to IS_ENABLED()

Quoted 7 lines

Thanks very much. Works well here.

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

#4 lore raw
Quoted 20 lines · Bartosz Golaszewski
Quoted 19 lines · David Gow

Le 08/07/2026 à 5:54 PM, Bartosz Golaszewski a écrit :

Quoted 7 lines

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.

Quoted 8 lines
Fixes 85347718ab0d ("bug/kunit: Core support for suppressing warning backtraces")

---
Changes in v2:
- drop the guard entirely instead of switching to IS_ENABLED()

Thanks very much. Works well here.

Quoted 9 lines
Quoted 5 lines

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