Skip to content

Add support for suppressing warning backtraces

Guenter Roeck dri-devel linux-arch linux-arm-kernel linux-doc linux-kselftest linux-parisc linux-riscv linux-s390 linux-sh linuxppc-dev lkml loongarch netdev 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest15 patches 11 repliesIn review
  2. v214 patches 8 repliesSuperseded
  3. v114 patches 15 repliesSuperseded

Changes in v3 from the cover letter

- 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

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15bug/kunit: Core support for suppressing warning backtracesinclude/asm-generic/bug.h include/kunit/bug.h include/kunit/test.h +5 more+178 -91 reply
2/15kunit: bug: Count suppressed warning backtracesinclude/kunit/bug.h lib/kunit/bug.c+9 -21 reply
3/15kunit: Add test cases for backtrace warning suppressionlib/kunit/Makefile lib/kunit/backtrace-suppression-test.c+109 -22 replies
4/15kunit: Add documentation for warning backtrace suppression APIDocumentation/dev-tools/kunit/usage.rst+29 -11 reply
5/15drm: Suppress intentional warning backtraces in scaling unit testsdrivers/gpu/drm/tests/drm_rect_test.c+16 -00 replies
6/15net: kunit: Suppress lock warning noise at end of dev_addr_lists testsnet/core/dev_addr_lists_test.c+6 -02 replies
7/15x86: Add support for suppressing warning backtracesarch/x86/include/asm/bug.h+16 -50 replies
8/15arm64: Add support for suppressing warning backtracesarch/arm64/include/asm/asm-bug.h arch/arm64/include/asm/bug.h+26 -110 replies
9/15loongarch: Add support for suppressing warning backtracesarch/loongarch/include/asm/bug.h+27 -110 replies
10/15parisc: Add support for suppressing warning backtracesarch/parisc/include/asm/bug.h+21 -80 replies
11/15s390: Add support for suppressing warning backtracesarch/s390/include/asm/bug.h+14 -30 replies
12/15sh: Add support for suppressing warning backtracesarch/sh/include/asm/bug.h+22 -40 replies
13/15sh: Move defines needed for suppressing warning backtracesarch/sh/include/asm/bug.h+9 -71 reply
14/15riscv: Add support for suppressing warning backtracesarch/riscv/include/asm/bug.h+26 -121 reply
15/15powerpc: Add support for suppressing warning backtracesarch/powerpc/include/asm/bug.h+28 -91 reply

Reviews trailers per patch

14 of 15 patches have a Reviewed-by or Acked-by.

PatchLinux Kernel Functional TestingDan CarpenterKees CookMaíra CanalHelge DellerMichael EllermanDavid GowCharlie Jenkins
SeriesT-b
1/15T-b A-b R-b
2/15T-b A-b R-b R-b
3/15T-b A-b R-b
4/15T-b A-b R-b R-b
5/15T-b A-b A-b
6/15T-b A-b
7/15T-b A-b
8/15T-b A-b
9/15T-b A-b
10/15T-b A-b A-b
11/15T-b A-b
12/15T-b A-b
13/15
14/15T-b A-b R-b
15/15T-b A-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 8 reviewers.

Read the v3 thread

Cover letter [PATCH v3 00/15] Add support for suppressing warning backtraces

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 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, it 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 identify and suppress specific warning backtraces while executing test code. Support suppressing multiple backtraces while at the same time limiting changes to generic code to the absolute minimum. Architecture specific changes are kept at minimum by retaining function names only if both CONFIG_DEBUG_BUGVERBOSE and CONFIG_KUNIT are enabled.

The first patch of the series introduces the necessary infrastructure. The second patch introduces support for counting suppressed backtraces. This capability is used in patch three to implement unit tests. Patch four documents the new API.
The next two patches add support for suppressing backtraces in drm_rect and dev_addr_lists unit tests. These patches are intended to serve as examples for the use of the functionality introduced with this series. The remaining patches implement the necessary changes for all architectures with GENERIC_BUG support.

With CONFIG_KUNIT enabled, image size increase with this series applied is approximately 1%. The image size increase (and with it the functionality introduced by this series) can be avoided by disabling CONFIG_KUNIT_SUPPRESS_BACKTRACE.

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.

Design note:
Function pointers are only added to the __bug_table section if both CONFIG_KUNIT_SUPPRESS_BACKTRACE and CONFIG_DEBUG_BUGVERBOSE are enabled to avoid image size increases if CONFIG_KUNIT is disabled. There would be some benefits to adding those pointers all the time (reduced complexity, ability to display function names in BUG/WARNING messages). That change, if desired, can be made later.

Checkpatch note:
Remaining checkpatch errors and warnings were deliberately ignored. Some are triggered by matching coding style or by comments interpreted as code, others by assembler macros which are disliked by checkpatch. Suggestions for improvements are welcome.

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

----------------------------------------------------------------
Guenter Roeck (15):
bug/kunit: Core support for suppressing warning backtraces
kunit: bug: Count suppressed warning backtraces
kunit: Add test cases for backtrace warning suppression
kunit: Add documentation for warning backtrace suppression API
drm: Suppress intentional warning backtraces in scaling unit tests
net: kunit: Suppress lock warning noise at end of dev_addr_lists tests
x86: Add support for suppressing warning backtraces
arm64: Add support for suppressing warning backtraces
loongarch: Add support for suppressing warning backtraces
parisc: Add support for suppressing warning backtraces
s390: Add support for suppressing warning backtraces
sh: Add support for suppressing warning backtraces
sh: Move defines needed for suppressing warning backtraces
riscv: Add support for suppressing warning backtraces
powerpc: Add support for suppressing warning backtraces

 Documentation/dev-tools/kunit/usage.rst |  30 ++++++++-
 arch/arm64/include/asm/asm-bug.h        |  29 ++++++---
 arch/arm64/include/asm/bug.h            |   8 ++-
 arch/loongarch/include/asm/bug.h        |  38 ++++++++----
 arch/parisc/include/asm/bug.h           |  29 ++++++---
 arch/powerpc/include/asm/bug.h          |  37 +++++++++---
 arch/riscv/include/asm/bug.h            |  38 ++++++++----
 arch/s390/include/asm/bug.h             |  17 +++++-
 arch/sh/include/asm/bug.h               |  28 +++++++--
 arch/x86/include/asm/bug.h              |  21 +++++--
 drivers/gpu/drm/tests/drm_rect_test.c   |  16 +++++
 include/asm-generic/bug.h               |  16 ++++-
 include/kunit/bug.h                     |  56 +++++++++++++++++
 include/kunit/test.h                    |   1 +
 include/linux/bug.h                     |  13 ++++
 lib/bug.c                               |  51 ++++++++++++++--
 lib/kunit/Kconfig                       |   9 +++
 lib/kunit/Makefile                      |   7 ++-
 lib/kunit/backtrace-suppression-test.c  | 104 ++++++++++++++++++++++++++++++++
 lib/kunit/bug.c                         |  42 +++++++++++++
 net/core/dev_addr_lists_test.c          |   6 ++
 21 files changed, 524 insertions(+), 72 deletions(-)
 create mode 100644 include/kunit/bug.h
 create mode 100644 lib/kunit/backtrace-suppression-test.c
 create mode 100644 lib/kunit/bug.c