Skip to content

Commit a5fcc23

Browse files
pmladekakpm00
authored andcommitted
watchdog/hardlockup: make HAVE_NMI_WATCHDOG sparc64-specific
There are several hardlockup detector implementations and several Kconfig values which allow selection and build of the preferred one. CONFIG_HARDLOCKUP_DETECTOR was introduced by the commit 23637d4 ("lockup_detector: Introduce CONFIG_HARDLOCKUP_DETECTOR") in v2.6.36. It was a preparation step for introducing the new generic perf hardlockup detector. The existing arch-specific variants did not support the to-be-created generic build configurations, sysctl interface, etc. This distinction was made explicit by the commit 4a7863c ("x86, nmi_watchdog: Remove ARCH_HAS_NMI_WATCHDOG and rely on CONFIG_HARDLOCKUP_DETECTOR") in v2.6.38. CONFIG_HAVE_NMI_WATCHDOG was introduced by the commit d314d74 ("nmi watchdog: do not use cpp symbol in Kconfig") in v3.4-rc1. It replaced the above mentioned ARCH_HAS_NMI_WATCHDOG. At that time, it was still used by three architectures, namely blackfin, mn10300, and sparc. The support for blackfin and mn10300 architectures has been completely dropped some time ago. And sparc is the only architecture with the historic NMI watchdog at the moment. And the old sparc implementation is really special. It is always built on sparc64. It used to be always enabled until the commit 7a5c8b5 ("sparc: implement watchdog_nmi_enable and watchdog_nmi_disable") added in v4.10-rc1. There are only few locations where the sparc64 NMI watchdog interacts with the generic hardlockup detectors code: + implements arch_touch_nmi_watchdog() which is called from the generic touch_nmi_watchdog() + implements watchdog_hardlockup_enable()/disable() to support /proc/sys/kernel/nmi_watchdog + is always preferred over other generic watchdogs, see CONFIG_HARDLOCKUP_DETECTOR + includes asm/nmi.h into linux/nmi.h because some sparc-specific functions are needed in sparc-specific code which includes only linux/nmi.h. The situation became more complicated after the commit 05a4a95 ("kernel/watchdog: split up config options") and commit 2104180 ("powerpc/64s: implement arch-specific hardlockup watchdog") in v4.13-rc1. They introduced HAVE_HARDLOCKUP_DETECTOR_ARCH. It was used for powerpc specific hardlockup detector. It was compatible with the perf one regarding the general boot, sysctl, and programming interfaces. HAVE_HARDLOCKUP_DETECTOR_ARCH was defined as a superset of HAVE_NMI_WATCHDOG. It made some sense because all arch-specific detectors had some common requirements, namely: + implemented arch_touch_nmi_watchdog() + included asm/nmi.h into linux/nmi.h + defined the default value for /proc/sys/kernel/nmi_watchdog But it actually has made things pretty complicated when the generic buddy hardlockup detector was added. Before the generic perf detector was newer supported together with an arch-specific one. But the buddy detector could work on any SMP system. It means that an architecture could support both the arch-specific and buddy detector. As a result, there are few tricky dependencies. For example, CONFIG_HARDLOCKUP_DETECTOR depends on: ((HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY) && !HAVE_NMI_WATCHDOG) || HAVE_HARDLOCKUP_DETECTOR_ARCH The problem is that the very special sparc implementation is defined as: HAVE_NMI_WATCHDOG && !HAVE_HARDLOCKUP_DETECTOR_ARCH Another problem is that the meaning of HAVE_NMI_WATCHDOG is far from clear without reading understanding the history. Make the logic less tricky and more self-explanatory by making HAVE_NMI_WATCHDOG specific for the sparc64 implementation. And rename it to HAVE_HARDLOCKUP_DETECTOR_SPARC64. Note that HARDLOCKUP_DETECTOR_PREFER_BUDDY, HARDLOCKUP_DETECTOR_PERF, and HARDLOCKUP_DETECTOR_BUDDY may conflict only with HAVE_HARDLOCKUP_DETECTOR_ARCH. They depend on HARDLOCKUP_DETECTOR and it is not longer enabled when HAVE_NMI_WATCHDOG is set. Link: https://lkml.kernel.org/r/20230616150618.6073-5-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 0c68bda commit a5fcc23

6 files changed

Lines changed: 18 additions & 33 deletions

File tree

arch/Kconfig

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -400,33 +400,15 @@ config HAVE_HARDLOCKUP_DETECTOR_PERF
400400
The arch chooses to use the generic perf-NMI-based hardlockup
401401
detector. Must define HAVE_PERF_EVENTS_NMI.
402402

403-
config HAVE_NMI_WATCHDOG
404-
depends on HAVE_NMI
405-
bool
406-
help
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.
416-
417403
config HAVE_HARDLOCKUP_DETECTOR_ARCH
418404
bool
419-
select HAVE_NMI_WATCHDOG
420405
help
421406
The arch provides its own hardlockup detector implementation instead
422407
of the generic ones.
423408

424409
It uses the same command line parameters, and sysctl interface,
425410
as the generic hardlockup detectors.
426411

427-
HAVE_NMI_WATCHDOG is selected to build the code shared with
428-
the sparc64 specific implementation.
429-
430412
config HAVE_PERF_REGS
431413
bool
432414
help

arch/sparc/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ config SPARC
3333
select ARCH_WANT_IPC_PARSE_VERSION
3434
select GENERIC_PCI_IOMAP
3535
select HAS_IOPORT
36-
select HAVE_NMI_WATCHDOG if SPARC64
36+
select HAVE_HARDLOCKUP_DETECTOR_SPARC64 if SPARC64
3737
select HAVE_CBPF_JIT if SPARC32
3838
select HAVE_EBPF_JIT if SPARC64
3939
select HAVE_DEBUG_BUGVERBOSE

arch/sparc/Kconfig.debug

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,12 @@ config FRAME_POINTER
1414
bool
1515
depends on MCOUNT
1616
default y
17+
18+
config HAVE_HARDLOCKUP_DETECTOR_SPARC64
19+
depends on HAVE_NMI
20+
bool
21+
help
22+
Sparc64 hardlockup detector is the last one developed before adding
23+
the common infrastructure for handling hardlockup detectors. It is
24+
always built. It does _not_ use the common command line parameters
25+
and sysctl interface, except for /proc/sys/kernel/nmi_watchdog.

include/linux/nmi.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <asm/irq.h>
1010

1111
/* Arch specific watchdogs might need to share extra watchdog-related APIs. */
12-
#if defined(CONFIG_HAVE_NMI_WATCHDOG)
12+
#if defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_ARCH) || defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64)
1313
#include <asm/nmi.h>
1414
#endif
1515

@@ -90,8 +90,7 @@ static inline void hardlockup_detector_disable(void) {}
9090
#endif
9191

9292
/* Sparc64 has special implemetantion that is always enabled. */
93-
#if defined(CONFIG_HARDLOCKUP_DETECTOR) || \
94-
(defined(CONFIG_HAVE_NMI_WATCHDOG) && !defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_ARCH))
93+
#if defined(CONFIG_HARDLOCKUP_DETECTOR) || defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64)
9594
void arch_touch_nmi_watchdog(void);
9695
#else
9796
static inline void arch_touch_nmi_watchdog(void) { }

kernel/watchdog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
static DEFINE_MUTEX(watchdog_mutex);
3131

32-
#if defined(CONFIG_HARDLOCKUP_DETECTOR) || defined(CONFIG_HAVE_NMI_WATCHDOG)
32+
#if defined(CONFIG_HARDLOCKUP_DETECTOR) || defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64)
3333
# define WATCHDOG_HARDLOCKUP_DEFAULT 1
3434
#else
3535
# define WATCHDOG_HARDLOCKUP_DEFAULT 0

lib/Kconfig.debug

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,15 +1050,10 @@ config HAVE_HARDLOCKUP_DETECTOR_BUDDY
10501050
# sparc64: has a custom implementation which is not using the common
10511051
# hardlockup command line options and sysctl interface.
10521052
#
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.
1057-
#
10581053
config HARDLOCKUP_DETECTOR
10591054
bool "Detect Hard Lockups"
1060-
depends on DEBUG_KERNEL && !S390
1061-
depends on ((HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY) && !HAVE_NMI_WATCHDOG) || HAVE_HARDLOCKUP_DETECTOR_ARCH
1055+
depends on DEBUG_KERNEL && !S390 && !HAVE_HARDLOCKUP_DETECTOR_SPARC64
1056+
depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY || HAVE_HARDLOCKUP_DETECTOR_ARCH
10621057
imply HARDLOCKUP_DETECTOR_PERF
10631058
imply HARDLOCKUP_DETECTOR_BUDDY
10641059
select LOCKUP_DETECTOR
@@ -1079,7 +1074,7 @@ config HARDLOCKUP_DETECTOR_PREFER_BUDDY
10791074
bool "Prefer the buddy CPU hardlockup detector"
10801075
depends on HARDLOCKUP_DETECTOR
10811076
depends on HAVE_HARDLOCKUP_DETECTOR_PERF && HAVE_HARDLOCKUP_DETECTOR_BUDDY
1082-
depends on !HAVE_NMI_WATCHDOG
1077+
depends on !HAVE_HARLOCKUP_DETECTOR_ARCH
10831078
help
10841079
Say Y here to prefer the buddy hardlockup detector over the perf one.
10851080

@@ -1095,15 +1090,15 @@ config HARDLOCKUP_DETECTOR_PERF
10951090
bool
10961091
depends on HARDLOCKUP_DETECTOR
10971092
depends on HAVE_HARDLOCKUP_DETECTOR_PERF && !HARDLOCKUP_DETECTOR_PREFER_BUDDY
1098-
depends on !HAVE_NMI_WATCHDOG
1093+
depends on !HAVE_HARDLOCKUP_DETECTOR_ARCH
10991094
select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER
11001095

11011096
config HARDLOCKUP_DETECTOR_BUDDY
11021097
bool
11031098
depends on HARDLOCKUP_DETECTOR
11041099
depends on HAVE_HARDLOCKUP_DETECTOR_BUDDY
11051100
depends on !HAVE_HARDLOCKUP_DETECTOR_PERF || HARDLOCKUP_DETECTOR_PREFER_BUDDY
1106-
depends on !HAVE_NMI_WATCHDOG
1101+
depends on !HAVE_HARDLOCKUP_DETECTOR_ARCH
11071102
select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER
11081103

11091104
#

0 commit comments

Comments
 (0)