Skip to content

Commit 1356d0b

Browse files
pmladekakpm00
authored andcommitted
watchdog/hardlockup: make the config checks more straightforward
There are four possible variants of hardlockup detectors: + buddy: available when SMP is set. + perf: available when HAVE_HARDLOCKUP_DETECTOR_PERF is set. + arch-specific: available when HAVE_HARDLOCKUP_DETECTOR_ARCH is set. + sparc64 special variant: available when HAVE_NMI_WATCHDOG is set and HAVE_HARDLOCKUP_DETECTOR_ARCH is not set. The check for the sparc64 variant is more complicated because HAVE_NMI_WATCHDOG is used to #ifdef code used by both arch-specific and sparc64 specific variant. Therefore it is automatically selected with HAVE_HARDLOCKUP_DETECTOR_ARCH. This complexity is partly hidden in HAVE_HARDLOCKUP_DETECTOR_NON_ARCH. It reduces the size of some checks but it makes them harder to follow. Finally, the other temporary variable HARDLOCKUP_DETECTOR_NON_ARCH is used to re-compute HARDLOCKUP_DETECTOR_PERF/BUDDY when the global HARDLOCKUP_DETECTOR switch is enabled/disabled. Make the logic more straightforward by the following changes: + Better explain the role of HAVE_HARDLOCKUP_DETECTOR_ARCH and HAVE_NMI_WATCHDOG in comments. + Add HAVE_HARDLOCKUP_DETECTOR_BUDDY so that there is separate HAVE_* for all four hardlockup detector variants. Use it in the other conditions instead of SMP. It makes it clear that it is about the buddy detector. + Open code HAVE_HARDLOCKUP_DETECTOR_NON_ARCH in HARDLOCKUP_DETECTOR and HARDLOCKUP_DETECTOR_PREFER_BUDDY. It helps to understand the conditions between the four hardlockup detector variants. + Define the exact conditions when HARDLOCKUP_DETECTOR_PERF/BUDDY can be enabled. It explains the dependency on the other hardlockup detector variants. Also it allows to remove HARDLOCKUP_DETECTOR_NON_ARCH by using "imply". It triggers re-evaluating HARDLOCKUP_DETECTOR_PERF/BUDDY when the global HARDLOCKUP_DETECTOR switch is changed. + Add dependency on HARDLOCKUP_DETECTOR so that the affected variables disappear when the hardlockup detectors are disabled. Another nice side effect is that HARDLOCKUP_DETECTOR_PREFER_BUDDY value is not preserved when the global switch is disabled. The user has to make the decision again when it gets re-enabled. Link: https://lkml.kernel.org/r/20230616150618.6073-3-pmladek@suse.com Signed-off-by: Petr Mladek <pmladek@suse.com> Reviewed-by: Douglas Anderson <dianders@chromium.org> Cc: Christophe Leroy <christophe.leroy@csgroup.eu> Cc: "David S. Miller" <davem@davemloft.net> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 4917a25 commit 1356d0b

2 files changed

Lines changed: 53 additions & 32 deletions

File tree

arch/Kconfig

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -404,17 +404,28 @@ config HAVE_NMI_WATCHDOG
404404
depends on HAVE_NMI
405405
bool
406406
help
407-
The arch provides a low level NMI watchdog. It provides
408-
asm/nmi.h, and defines its own watchdog_hardlockup_probe() and
409-
arch_touch_nmi_watchdog().
407+
The arch provides its own hardlockup detector implementation instead
408+
of the generic ones.
409+
410+
Sparc64 defines this variable without HAVE_HARDLOCKUP_DETECTOR_ARCH.
411+
It is the last arch-specific implementation which was developed before
412+
adding the common infrastructure for handling hardlockup detectors.
413+
It is always built. It does _not_ use the common command line
414+
parameters and sysctl interface, except for
415+
/proc/sys/kernel/nmi_watchdog.
410416

411417
config HAVE_HARDLOCKUP_DETECTOR_ARCH
412418
bool
413419
select HAVE_NMI_WATCHDOG
414420
help
415-
The arch chooses to provide its own hardlockup detector, which is
416-
a superset of the HAVE_NMI_WATCHDOG. It also conforms to config
417-
interfaces and parameters provided by hardlockup detector subsystem.
421+
The arch provides its own hardlockup detector implementation instead
422+
of the generic ones.
423+
424+
It uses the same command line parameters, and sysctl interface,
425+
as the generic hardlockup detectors.
426+
427+
HAVE_NMI_WATCHDOG is selected to build the code shared with
428+
the sparc64 specific implementation.
418429

419430
config HAVE_PERF_REGS
420431
bool

lib/Kconfig.debug

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,16 +1035,33 @@ config BOOTPARAM_SOFTLOCKUP_PANIC
10351035

10361036
Say N if unsure.
10371037

1038+
config HAVE_HARDLOCKUP_DETECTOR_BUDDY
1039+
bool
1040+
depends on SMP
1041+
default y
1042+
1043+
#
1044+
# Global switch whether to build a hardlockup detector at all. It is available
1045+
# only when the architecture supports at least one implementation. There are
1046+
# two exceptions. The hardlockup detector is never enabled on:
10381047
#
1039-
# arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard
1040-
# lockup detector rather than the perf based detector.
1048+
# s390: it reported many false positives there
1049+
#
1050+
# sparc64: has a custom implementation which is not using the common
1051+
# hardlockup command line options and sysctl interface.
1052+
#
1053+
# Note that HAVE_NMI_WATCHDOG is used to distinguish the sparc64 specific
1054+
# implementaion. It is automatically enabled also for other arch-specific
1055+
# variants which set HAVE_HARDLOCKUP_DETECTOR_ARCH. It makes the check
1056+
# of avaialable and supported variants quite tricky.
10411057
#
10421058
config HARDLOCKUP_DETECTOR
10431059
bool "Detect Hard Lockups"
10441060
depends on DEBUG_KERNEL && !S390
1045-
depends on HAVE_HARDLOCKUP_DETECTOR_NON_ARCH || HAVE_HARDLOCKUP_DETECTOR_ARCH
1061+
depends on ((HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY) && !HAVE_NMI_WATCHDOG) || HAVE_HARDLOCKUP_DETECTOR_ARCH
1062+
imply HARDLOCKUP_DETECTOR_PERF
1063+
imply HARDLOCKUP_DETECTOR_BUDDY
10461064
select LOCKUP_DETECTOR
1047-
select HARDLOCKUP_DETECTOR_NON_ARCH if HAVE_HARDLOCKUP_DETECTOR_NON_ARCH
10481065

10491066
help
10501067
Say Y here to enable the kernel to act as a watchdog to detect
@@ -1055,9 +1072,14 @@ config HARDLOCKUP_DETECTOR
10551072
chance to run. The current stack trace is displayed upon detection
10561073
and the system will stay locked up.
10571074

1075+
#
1076+
# Note that arch-specific variants are always preferred.
1077+
#
10581078
config HARDLOCKUP_DETECTOR_PREFER_BUDDY
10591079
bool "Prefer the buddy CPU hardlockup detector"
1060-
depends on HAVE_HARDLOCKUP_DETECTOR_PERF && SMP
1080+
depends on HARDLOCKUP_DETECTOR
1081+
depends on HAVE_HARDLOCKUP_DETECTOR_PERF && HAVE_HARDLOCKUP_DETECTOR_BUDDY
1082+
depends on !HAVE_NMI_WATCHDOG
10611083
help
10621084
Say Y here to prefer the buddy hardlockup detector over the perf one.
10631085

@@ -1071,39 +1093,27 @@ config HARDLOCKUP_DETECTOR_PREFER_BUDDY
10711093

10721094
config HARDLOCKUP_DETECTOR_PERF
10731095
bool
1074-
depends on HAVE_HARDLOCKUP_DETECTOR_PERF
1096+
depends on HARDLOCKUP_DETECTOR
1097+
depends on HAVE_HARDLOCKUP_DETECTOR_PERF && !HARDLOCKUP_DETECTOR_PREFER_BUDDY
1098+
depends on !HAVE_NMI_WATCHDOG
10751099
select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER
10761100

10771101
config HARDLOCKUP_DETECTOR_BUDDY
10781102
bool
1079-
depends on SMP
1103+
depends on HARDLOCKUP_DETECTOR
1104+
depends on HAVE_HARDLOCKUP_DETECTOR_BUDDY
1105+
depends on !HAVE_HARDLOCKUP_DETECTOR_PERF || HARDLOCKUP_DETECTOR_PREFER_BUDDY
1106+
depends on !HAVE_NMI_WATCHDOG
10801107
select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER
10811108

1109+
#
10821110
# Both the "perf" and "buddy" hardlockup detectors count hrtimer
10831111
# interrupts. This config enables functions managing this common code.
1112+
#
10841113
config HARDLOCKUP_DETECTOR_COUNTS_HRTIMER
10851114
bool
10861115
select SOFTLOCKUP_DETECTOR
10871116

1088-
# For hardlockup detectors you can have one directly provided by the arch
1089-
# or use a "non-arch" one. If you're using a "non-arch" one that is
1090-
# further divided the perf hardlockup detector (which, confusingly, needs
1091-
# arch-provided perf support) and the buddy hardlockup detector (which just
1092-
# needs SMP). In either case, using the "non-arch" code conflicts with
1093-
# the NMI watchdog code (which is sometimes used directly and sometimes used
1094-
# by the arch-provided hardlockup detector).
1095-
config HAVE_HARDLOCKUP_DETECTOR_NON_ARCH
1096-
bool
1097-
depends on (HAVE_HARDLOCKUP_DETECTOR_PERF || SMP) && !HAVE_NMI_WATCHDOG
1098-
default y
1099-
1100-
# This will select the appropriate non-arch hardlockdup detector
1101-
config HARDLOCKUP_DETECTOR_NON_ARCH
1102-
bool
1103-
depends on HAVE_HARDLOCKUP_DETECTOR_NON_ARCH
1104-
select HARDLOCKUP_DETECTOR_BUDDY if !HAVE_HARDLOCKUP_DETECTOR_PERF || HARDLOCKUP_DETECTOR_PREFER_BUDDY
1105-
select HARDLOCKUP_DETECTOR_PERF if HAVE_HARDLOCKUP_DETECTOR_PERF && !HARDLOCKUP_DETECTOR_PREFER_BUDDY
1106-
11071117
#
11081118
# Enables a timestamp based low pass filter to compensate for perf based
11091119
# hard lockup detection which runs too fast due to turbo modes.

0 commit comments

Comments
 (0)