Le 16/06/2026 à 7:44 PM, Albert Esteve a écrit : > On Fri, May 15, 2026 at 2:29 PM Albert Esteve <[email protected]> wrote: >> >> Some unit tests intentionally trigger warning backtraces by passing bad >> parameters to kernel API functions. Such unit tests typically check the >> return value from such calls, not the existence of the warning backtrace. >> >> Such intentionally generated warning backtraces are neither desirable >> nor useful for a number of reasons: >> - They can result in overlooked real problems. >> - A warning that suddenly starts to show up in unit tests needs to be >> investigated and has to be marked to be ignored, for example by >> adjusting filter scripts. Such filters are ad hoc because there is >> no real standard format for warnings. On top of that, such filter >> scripts would require constant maintenance. >> >> One option to address the problem would be to add messages such as >> "expected warning backtraces start/end here" to the kernel log. >> However, that would again require filter scripts, might result in >> missing real problematic warning backtraces triggered while the test >> is running, and the irrelevant backtrace(s) would still clog the >> kernel log. >> >> Solve the problem by providing a means to suppress warning backtraces >> originating from the current kthread while executing test code. >> Since each KUnit test runs in its own kthread, this effectively scopes >> suppression to the test that enabled it, without requiring any >> architecture-specific code. >> >> Overview: >> Patch#1 Introduces the suppression infrastructure integrated into >> KUnit's hook mechanism. >> Patch#2 Adds selftests to validate the functionality. >> Patch#3 Demonstrates real-world usage in the DRM subsystem. >> Patch#4 Documents the new API and usage guidelines. >> >> Design Notes: >> Suppression is integrated into the existing KUnit hooks infrastructure, >> reusing the kunit_running static branch for zero overhead >> when no tests are running. The implementation lives entirely in the >> kunit module; only a static-inline wrapper and a function pointer >> slot are added to built-in code. >> >> Suppression is checked at three points in the warning path: >> - In `warn_slowpath_fmt()` (kernel/panic.c), for architectures without >> __WARN_FLAGS. The check runs before any output, fully suppressing >> both message and backtrace. >> - In `__warn_printk()` (kernel/panic.c), for architectures that define >> __WARN_FLAGS but not their own __WARN_printf (arm64, loongarch, >> parisc, powerpc, riscv, sh). The check suppresses the warning message >> text that is printed before the trap enters __report_bug(). >> - In `__report_bug()` (lib/bug.c), for architectures that define >> __WARN_FLAGS. The check runs before `__warn()` is called, suppressing >> the backtrace and stack dump. >> >> To avoid double-counting on architectures where both `__warn_printk()` >> and `__report_bug()` run for the same warning, the hook takes a bool >> parameter: true to increment the suppression counter, false to suppress >> without counting. >> >> The suppression state is dynamically allocated via kunit_kzalloc() and >> tied to the KUnit test lifecycle via `kunit_add_action()`, ensuring >> automatic cleanup at test exit. Writer-side access to the global >> suppression list is serialized with a spinlock; readers use RCU. >> >> Two API forms are provided: >> - kunit_warning_suppress(test) { ... }: scoped blocks with automatic >> cleanup. The suppression handle is not accessible outside the block, >> so warning counts (if needed) must be checked inside. Multiple >> sequential suppression blocks are allowed. >> - kunit_start/end_suppress_warning(test): direct functions that return >> an explicit handle. Use when the handle needs to be retained, or passed >> across helpers. Multiple sequential suppression blocks are allowed. >> >> This series is based on the RFC patch and subsequent discussion at >> https://patchwork.kernel.org/project/linux-kselftest/patch/[email protected]/ >> and offers a more comprehensive solution of the problem discussed there. >> >> Changes since RFC: >> - Introduced CONFIG_KUNIT_SUPPRESS_BACKTRACE >> - Minor cleanups and bug fixes >> - Added support for all affected architectures >> - Added support for counting suppressed warnings >> - Added unit tests using those counters >> - Added patch to suppress warning backtraces in dev_addr_lists tests >> >> Changes since v1: >> - Rebased to v6.9-rc1 >> - Added Tested-by:, Acked-by:, and Reviewed-by: tags >> [I retained those tags since there have been no functional changes] >> - Introduced KUNIT_SUPPRESS_BACKTRACE configuration option, enabled by >> default. >> >> Changes since v2: >> - Rebased to v6.9-rc2 >> - Added comments to drm warning suppression explaining why it is needed. >> - Added patch to move conditional code in arch/sh/include/asm/bug.h >> to avoid kerneldoc warning >> - Added architecture maintainers to Cc: for architecture specific patches >> - No functional changes >> >> Changes since v3: >> - Rebased to v6.14-rc6 >> - Dropped net: "kunit: Suppress lock warning noise at end of dev_addr_lists >> tests" >> since 3db3b62955cd6d73afde05a17d7e8e106695c3b9 >> - Added __kunit_ and KUNIT_ prefixes. >> - Tested on interessed architectures. >> >> Changes since v4: >> - Rebased to v6.15-rc7 >> - Dropped all code in __report_bug() >> - Moved all checks in WARN*() macros. >> - Dropped all architecture specific code. >> - Made __kunit_is_suppressed_warning nice to noinstr functions. >> >> Changes since v5: >> - Rebased to v7.0-rc3 >> - Added RCU protection for the suppressed warnings list. >> - Added static key and branching optimization. >> - Removed custom `strcmp` implementation and reworked >> __kunit_is_suppressed_warning() entrypoint function. >> >> Changes since v6: >> - Moved suppression checks from WARN*() macros to warn_slowpath_fmt() >> and __report_bug(). >> - Replaced stack-allocated suppression struct with kunit_kzalloc() heap >> allocation tied to the KUnit test lifecycle. >> - Changed suppression strategy from function-name matching to task-scoped: >> all warnings on the current task are suppressed between START and END, >> rather than only warnings originating from a specific named function. >> - Simplified macro API: removed KUNIT_DECLARE_SUPPRESSED_WARNING(), >> the START macro now takes (test) and handles allocation internally. >> - Removed static key and branching optiomization, as by the time it >> was executed, callers are already in warn slowpaths. >> - Link to v6: >> https://lore.kernel.org/r/[email protected] >> >> Changes since v7: >> - Integrated suppression into existing KUnit hooks infrastructure >> - Removed CONFIG_KUNIT_SUPPRESS_BACKTRACE >> - Added suppression check in __warn_printk() >> - Added spinlock for writer-side RCU protection >> - Replaced explicit rcu_read_lock/unlock with guard(rcu)() >> - Added scoped API (kunit_warning_suppress) using __cleanup attribute >> - Updated DRM patch to use scoped API >> - Expanded self-tests: incremental counting, cross-kthread isolation >> - Rewrote documentation covering all three API forms with examples >> - Link to v7: >> https://lore.kernel.org/r/[email protected] >> >> Changes since v8: >> - Rebased to v7.1-rc2 >> - Remove KUNIT_START/END_SUPPRESSED_WARNING() macros >> - Add KUNIT_EXPECT_SUPPRESSED_WARNING_COUNT checks to drm tests >> - Link to v8: >> https://lore.kernel.org/r/[email protected] >> >> Changes since v9: >> - Fix silent false-pass when kunit_start_suppress_warning() returns NULL >> - Fix RCU lockdep splat for kunit_is_suppressed_warning() calls >> - Move disable_trace_on_warning() in __report_bug() >> - Make suppress counter atomic >> - Mark helper warn functions in selftest as noinline >> - Add kunit_skip() for CONFIG_BUG=n in selftests >> - Fix potentially uninitialized data.was_active in kthread seltest >> - Add kthread_stop() in kthread selftest early exit >> - Initialize scaling_factor to INT_MIN in DRM scaling tests >> - Add include for bool in test-bug.h to fix CONFIG_KUNIT=n case >> - Link to v9: >> https://lore.kernel.org/r/[email protected] >> >> Changes since v10: >> - Remove synchronize_rcu() to avoid sleeping in atomic context >> - Pin task_struct refcount to prevent ABA false-positive matches >> - Loop in suppression selftest to prevent use-after-free on kthread exit >> - Skip DRM rect tests on CONFIG_BUG=n >> - Link to v10: >> https://lore.kernel.org/r/[email protected] >> >> Changes since v11: >> - Use call_rcu() to defer free without blocking >> - Remove #ifdef CONFIG_KUNIT guard in lib/bug.c >> - Remove stale config checks from selftest >> - Replace skip on DRM rect tests with conditional expectation >> - Link to v11: >> https://lore.kernel.org/r/[email protected] >> >> Changes since v12: >> - Reverted to the v9 synchronize_rcu() approach >> - Add in_task() check at the top of __kunit_is_suppressed_warning_impl() >> - Link to v12: >> https://lore.kernel.org/r/[email protected] > > Hi all, > > I am not sure if there is a decision to merge this series or if any > work remains to be done. > > I reckon I sent a few versions back-to-back last time as I was > struggling with Sashiko. However, there are no significant changes, > the core strategy remains unchanged, involving only the addition of > safety checks and the removal of some redundancies to satisfy the AI. > I am just clarifying in case the last versions/respins were unclear. I > tried running AI reviews locally but Sashiko always found more issues > than my local model could. > The latest version was fine. It's just landed for 7.2: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=42eb3a5ef6bc56192bf450c79a3f274e081f8131
Thanks for all of your work, -- David

