watchdog/hardlockup: Cleanup configuration of hardlockup detectors
Subsystems (3)
cover watchdog/hardlockup: Cleanup configuration of hardlockup detectors
Hi,
this patchset is supposed to replace the last patch in the patchset cleaning up after introducing the buddy detector, see
https://lore.kernel.org/r/20230526184139.10.I821fe7609e57608913fe05abd8f35b343e7a9aae@changeid
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.
Only one hardlockup detector can be compiled in. The selection is done using quite complex dependencies between several CONFIG variables. The following patches will try to make it more straightforward.
Before, the decision was done using the following variables:
+ HAVE_HARDLOCKUP_DETECTOR_PERF
+ HAVE_HARDLOCKUP_DETECTOR_BUDDY
+ HAVE_HARDLOCKUP_DETECTOR_ARCH
+ HAVE_NMI_WATCHDOG
+ HARDLOCKUP_DETECTOR
+ HARDLOCKUP_DETECTOR_PREFER_BUDDY
+ HAVE_HARDLOCKUP_DETECTOR_NON_ARCH
+ HARDLOCKUP_DETECTOR_NON_ARCH
+ HARDLOCKUP_DETECTOR_PERF
+ HARDLOCKUP_DETECTOR_BUDDY
and the particular watchdog was used when the following variables were set:
+ perf: HARDLOCKUP_DETECTOR_PERF
+ buddy: HARDLOCKUP_DETECTOR_BUDDY
+ arch-specific: HAVE_HARDLOCKUP_DETECTOR_ARCH
+ sparc64: HAVE_NMI_WATCHDOG && !HAVE_HARDLOCKUP_DETECTOR_ARCH
After, the decision is done using the following variables:
+ HAVE_HARDLOCKUP_DETECTOR_PERF
+ HAVE_HARDLOCKUP_DETECTOR_BUDDY
+ HAVE_HARDLOCKUP_DETECTOR_ARCH
+ HAVE_HARDLOCKUP_DETECTOR_SPARC64
+ HARDLOCKUP_DETECTOR
+ HARDLOCKUP_DETECTOR_PREFER_BUDDY
+ HARDLOCKUP_DETECTOR_PERF
+ HARDLOCKUP_DETECTOR_BUDDY
+ HARDLOCKUP_DETECTOR_ARCH
+ HARDLOCKUP_DETECTOR_SPARC64
and the particular watchdog is used when one of these variables is set:
+ perf: HARDLOCKUP_DETECTOR_PERF
+ buddy: HARDLOCKUP_DETECTOR_BUDDY
+ arch-specific: HARDLOCKUP_DETECTOR_ARCH
+ sparc64: HARDLOCKUP_DETECTOR_SPARC64
Plus, many checks are more straightforward and even self-explanatory.
I build and run tested it on x86_64. I only checked the generated .config after using sparc_defconfig, sparc64_defconfig, ppc64_defconfig, and ppc40x_defconfig.
Best Regards,
Petr
Petr Mladek (7):
watchdog/hardlockup: Sort hardlockup detector related config values a
logical way
watchdog/hardlockup: Make the config checks more straightforward watchdog/hardlockup: Declare arch_touch_nmi_watchdog() only in
linux/nmi.h
watchdog/hardlockup: Enable HAVE_NMI_WATCHDOG only on sparc64 watchdog/sparc64: Rename HAVE_NMI_WATCHDOG to
HAVE_HARDLOCKUP_WATCHDOG_SPARC64
watchdog/sparc64: Define HARDLOCKUP_DETECTOR_SPARC64 watchdog/hardlockup: Define HARDLOCKUP_DETECTOR_ARCH
arch/Kconfig | 17 ++--- arch/powerpc/Kconfig | 5 +- arch/powerpc/include/asm/nmi.h | 2 - arch/sparc/Kconfig | 2 +- arch/sparc/Kconfig.debug | 20 ++++++ arch/sparc/include/asm/nmi.h | 1 - include/linux/nmi.h | 14 ++-- kernel/watchdog.c | 2 +- lib/Kconfig.debug | 115 +++++++++++++++++++-------------- 9 files changed, 104 insertions(+), 74 deletions(-)
Signature · 1 line
2.35.3
PATCH 1/7 watchdog/hardlockup: Sort hardlockup detector related config values a logical way
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.
Only one hardlockup detector can be compiled in. The selection is done using quite complex dependencies between several CONFIG variables. The following patches will try to make it more straightforward.
As a first step, reorder the definitions of the various CONFIG variables. The logical order is:
1. HAVE_* variables define available variants. They are typically defined in the arch/ config files.
2. HARDLOCKUP_DETECTOR y/n variable defines whether the hardlockup detector is enabled at all.
3. HARDLOCKUP_DETECTOR_PREFER_BUDDY y/n variable defines whether the buddy detector should be preferred over the perf one. Note that the arch specific variants are always preferred when available.
4. HARDLOCKUP_DETECTOR_PERF/BUDDY variables define whether the given detector is enabled in the end.
5. HAVE_HARDLOCKUP_DETECTOR_NON_ARCH and HARDLOCKUP_DETECTOR_NON_ARCH are temporary variables that are going to be removed in a followup patch.
The patch just shuffles the definitions. It should not change the existing behavior.
--- lib/Kconfig.debug | 112 +++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 56 deletions(-)
lib/Kconfig.debug +56 -56
@@ -1035,62 +1035,6 @@ config BOOTPARAM_SOFTLOCKUP_PANIC Say N if unsure. -# Both the "perf" and "buddy" hardlockup detectors count hrtimer -# interrupts. This config enables functions managing this common code. -config HARDLOCKUP_DETECTOR_COUNTS_HRTIMER - bool - select SOFTLOCKUP_DETECTOR - -config HARDLOCKUP_DETECTOR_PERF - bool - depends on HAVE_HARDLOCKUP_DETECTOR_PERF - select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER - -config HARDLOCKUP_DETECTOR_BUDDY - bool - depends on SMP - select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER - -# For hardlockup detectors you can have one directly provided by the arch -# or use a "non-arch" one. If you're using a "non-arch" one that is -# further divided the perf hardlockup detector (which, confusingly, needs -# arch-provided perf support) and the buddy hardlockup detector (which just -# needs SMP). In either case, using the "non-arch" code conflicts with -# the NMI watchdog code (which is sometimes used directly and sometimes used -# by the arch-provided hardlockup detector). -config HAVE_HARDLOCKUP_DETECTOR_NON_ARCH - bool - depends on (HAVE_HARDLOCKUP_DETECTOR_PERF || SMP) && !HAVE_NMI_WATCHDOG - default y - -config HARDLOCKUP_DETECTOR_PREFER_BUDDY - bool "Prefer the buddy CPU hardlockup detector" - depends on HAVE_HARDLOCKUP_DETECTOR_PERF && SMP - help - Say Y here to prefer the buddy hardlockup detector over the perf one. - - With the buddy detector, each CPU uses its softlockup hrtimer - to check that the next CPU is processing hrtimer interrupts by - verifying that a counter is increasing. - - This hardlockup detector is useful on systems that don't have - an arch-specific hardlockup detector or if resources needed - for the hardlockup detector are better used for other things. - -# This will select the appropriate non-arch hardlockdup detector -config HARDLOCKUP_DETECTOR_NON_ARCH - bool - depends on HAVE_HARDLOCKUP_DETECTOR_NON_ARCH - select HARDLOCKUP_DETECTOR_BUDDY if !HAVE_HARDLOCKUP_DETECTOR_PERF || HARDLOCKUP_DETECTOR_PREFER_BUDDY - select HARDLOCKUP_DETECTOR_PERF if HAVE_HARDLOCKUP_DETECTOR_PERF && !HARDLOCKUP_DETECTOR_PREFER_BUDDY - -# -# Enables a timestamp based low pass filter to compensate for perf based -# hard lockup detection which runs too fast due to turbo modes. -# -config HARDLOCKUP_CHECK_TIMESTAMP - bool - # # arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard # lockup detector rather than the perf based detector.
@@ -1111,6 +1055,62 @@ config HARDLOCKUP_DETECTOR chance to run. The current stack trace is displayed upon detection and the system will stay locked up. +config HARDLOCKUP_DETECTOR_PREFER_BUDDY + bool "Prefer the buddy CPU hardlockup detector" + depends on HAVE_HARDLOCKUP_DETECTOR_PERF && SMP + help + Say Y here to prefer the buddy hardlockup detector over the perf one. + + With the buddy detector, each CPU uses its softlockup hrtimer + to check that the next CPU is processing hrtimer interrupts by + verifying that a counter is increasing. + + This hardlockup detector is useful on systems that don't have + an arch-specific hardlockup detector or if resources needed + for the hardlockup detector are better used for other things. + +config HARDLOCKUP_DETECTOR_PERF + bool + depends on HAVE_HARDLOCKUP_DETECTOR_PERF + select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER + +config HARDLOCKUP_DETECTOR_BUDDY + bool + depends on SMP + select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER + +# Both the "perf" and "buddy" hardlockup detectors count hrtimer +# interrupts. This config enables functions managing this common code. +config HARDLOCKUP_DETECTOR_COUNTS_HRTIMER + bool + select SOFTLOCKUP_DETECTOR + +# For hardlockup detectors you can have one directly provided by the arch +# or use a "non-arch" one. If you're using a "non-arch" one that is +# further divided the perf hardlockup detector (which, confusingly, needs +# arch-provided perf support) and the buddy hardlockup detector (which just +# needs SMP). In either case, using the "non-arch" code conflicts with +# the NMI watchdog code (which is sometimes used directly and sometimes used +# by the arch-provided hardlockup detector). +config HAVE_HARDLOCKUP_DETECTOR_NON_ARCH + bool + depends on (HAVE_HARDLOCKUP_DETECTOR_PERF || SMP) && !HAVE_NMI_WATCHDOG + default y + +# This will select the appropriate non-arch hardlockdup detector +config HARDLOCKUP_DETECTOR_NON_ARCH + bool + depends on HAVE_HARDLOCKUP_DETECTOR_NON_ARCH + select HARDLOCKUP_DETECTOR_BUDDY if !HAVE_HARDLOCKUP_DETECTOR_PERF || HARDLOCKUP_DETECTOR_PREFER_BUDDY + select HARDLOCKUP_DETECTOR_PERF if HAVE_HARDLOCKUP_DETECTOR_PERF && !HARDLOCKUP_DETECTOR_PREFER_BUDDY + +# +# Enables a timestamp based low pass filter to compensate for perf based +# hard lockup detection which runs too fast due to turbo modes. +# +config HARDLOCKUP_CHECK_TIMESTAMP + bool + config BOOTPARAM_HARDLOCKUP_PANIC bool "Panic (Reboot) On Hard Lockups" depends on HARDLOCKUP_DETECTOR
Signature · 1 line
2.35.3
PATCH 4/7 watchdog/hardlockup: Enable HAVE_NMI_WATCHDOG only on sparc64
In reply to Petr MladekHAVE_NMI_WATCHDOG is always enabled when SPARC64 is enabled. The sparc64 implementation is special. It does not support the generic hardlockup related Kconfig values, command line parameters, and sysctl interface. Instead it is enabled/disabled by the top-level watchdog interface that is common for both softlockup and hardlockup detectors.
As a result, sparc64 needs special treating in Kconfig and source files. The checks are a bit complicated because HAVE_NMI_WATCHDOG is automatically set when HAVE_HARDLOCKUP_DETECTOR_ARCH is set. But HAVE_HARDLOCKUP_DETECTOR_ARCH is set when the arch specific implementation uses the generic hardlockup detector related Kconfig variables, command line parameters, and sysctl interface.
The motivation probably was to avoid changes in the code when the powerpc64-specific watchdog introduced HAVE_HARDLOCKUP_DETECTOR_ARCH. It probably allowed to re-use some existing checks for HAVE_NMI_WATCHDOG.
But it actually made things pretty complicated. For example, the following check was needed in HARDLOCKUP_DETECTOR config variable:
depends on ((HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY) && !HAVE_NMI_WATCHDOG) || HAVE_HARDLOCKUP_DETECTOR_ARCH
The inverted logic makes things easier:
+ HAVE_NMI_WATCHDOG is used only on sparc64. It is clear when the sparc64 specific watchdog is used.
+ HAVE_HARDLOCKUP_DETECTOR_ARCH is basically compatible with the generic watchdogs. As a result, the common code is marked by ifdef CONFIG_HARDLOCKUP_DETECTOR.
As a result:
+ Some conditions are easier.
+ Some conditions use HAVE_HARDLOCKUP_DETECTOR_ARCH instead of HAVE_NMI_WATCHDOG.
Note that HARDLOCKUP_DETECTOR_PREFER_BUDDY, HARDLOCKUP_DETECTOR_PERF, and HARDLOCKUP_DETECTOR_BUDDY might depend only on HAVE_HARDLOCKUP_DETECTOR_ARCH. They depend on HARDLOCKUP_DETECTOR and it is not longer enabled when HAVE_NMI_WATCHDOG is set.
Note that asm/nmi.h still has to be included for all arch-specific watchdogs. It declares more functions that are used in another arch specific code which includes only linux/nmi.h.
--- arch/Kconfig | 7 +------ include/linux/nmi.h | 5 ++--- lib/Kconfig.debug | 16 +++++++--------- 3 files changed, 10 insertions(+), 18 deletions(-)
arch/Kconfig +1 -6
@@ -404,10 +404,9 @@ config HAVE_NMI_WATCHDOG depends on HAVE_NMI bool help - The arch provides its own hardlockup detector implementation instead + Sparc64 provides its own hardlockup detector implementation instead of the generic perf one. - Sparc64 defines this variable without HAVE_HARDLOCKUP_DETECTOR_ARCH. It does _not_ use the command line parameters and sysctl interface used by generic hardlockup detectors. Instead it is enabled/disabled by the top-level watchdog interface that is common for both softlockup
@@ -415,7 +414,6 @@ config HAVE_NMI_WATCHDOG config HAVE_HARDLOCKUP_DETECTOR_ARCH bool - select HAVE_NMI_WATCHDOG help The arch provides its own hardlockup detector implementation instead of the generic ones.
@@ -423,9 +421,6 @@ config HAVE_HARDLOCKUP_DETECTOR_ARCH It uses the same command line parameters, and sysctl interface, as the generic hardlockup detectors. - HAVE_NMI_WATCHDOG is selected to build the code shared with - the sparc64 specific implementation. - config HAVE_PERF_REGS bool help
include/linux/nmi.h +2 -3
@@ -9,7 +9,7 @@#include <asm/irq.h> /* Arch specific watchdogs might need to share extra watchdog-related APIs. */ -#if defined(CONFIG_HAVE_NMI_WATCHDOG ) +#if defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_ARCH ) || defined(CONFIG_HAVE_NMI_WATCHDOG )#include <asm/nmi.h> #endif
@@ -92,8 +92,7 @@ static inline void hardlockup_detector_disable(void) {}#endif /* Sparc64 has special implemetantion that is always enabled. */ -#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || \ - (defined(CONFIG_HAVE_NMI_WATCHDOG ) && !defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_ARCH )) +#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_NMI_WATCHDOG )void arch_touch_nmi_watchdog (void );#else static inline void arch_touch_nmi_watchdog (void ) { }
lib/Kconfig.debug +7 -9
@@ -1050,15 +1050,13 @@ config HAVE_HARDLOCKUP_DETECTOR_BUDDY # sparc64: has a custom implementation which is not using the common # hardlockup command line options and sysctl interface. # -# Note that HAVE_NMI_WATCHDOG is used to distinguish the sparc64 specific -# implementaion. It is automatically enabled also for other arch-specific -# variants which set HAVE_HARDLOCKUP_DETECTOR_ARCH. It makes the check -# of avaialable and supported variants quite tricky. +# Note that HAVE_NMI_WATCHDOG is set when the sparc64 specific implementation +# is used. # config HARDLOCKUP_DETECTOR bool "Detect Hard Lockups" - depends on DEBUG_KERNEL && !S390 - depends on ((HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY) && !HAVE_NMI_WATCHDOG) || HAVE_HARDLOCKUP_DETECTOR_ARCH + depends on DEBUG_KERNEL && !S390 && !HAVE_NMI_WATCHDOG + depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY || HAVE_HARDLOCKUP_DETECTOR_ARCH imply HARDLOCKUP_DETECTOR_PERF imply HARDLOCKUP_DETECTOR_BUDDY select LOCKUP_DETECTOR
@@ -1079,7 +1077,7 @@ config HARDLOCKUP_DETECTOR_PREFER_BUDDY bool "Prefer the buddy CPU hardlockup detector" depends on HARDLOCKUP_DETECTOR depends on HAVE_HARDLOCKUP_DETECTOR_PERF && HAVE_HARDLOCKUP_DETECTOR_BUDDY - depends on !HAVE_NMI_WATCHDOG + depends on !HAVE_HARLOCKUP_DETECTOR_ARCH default n help Say Y here to prefer the buddy hardlockup detector over the perf one.
@@ -1096,7 +1094,7 @@ config HARDLOCKUP_DETECTOR_PERF bool depends on HARDLOCKUP_DETECTOR depends on HAVE_HARDLOCKUP_DETECTOR_PERF && !HARDLOCKUP_DETECTOR_PREFER_BUDDY - depends on !HAVE_NMI_WATCHDOG + depends on !HAVE_HARDLOCKUP_DETECTOR_ARCH select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER config HARDLOCKUP_DETECTOR_BUDDY
@@ -1104,7 +1102,7 @@ config HARDLOCKUP_DETECTOR_BUDDY depends on HARDLOCKUP_DETECTOR depends on HAVE_HARDLOCKUP_DETECTOR_BUDDY depends on !HAVE_HARDLOCKUP_DETECTOR_PERF || HARDLOCKUP_DETECTOR_PREFER_BUDDY - depends on !HAVE_NMI_WATCHDOG + depends on !HAVE_HARDLOCKUP_DETECTOR_ARCH select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER #
Signature · 1 line
2.35.3
PATCH 2/7 watchdog/hardlockup: Make the config checks more straightforward
In reply to Petr MladekThere 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 when it is enabled again.
--- arch/Kconfig | 22 ++++++++++++----- lib/Kconfig.debug | 63 ++++++++++++++++++++++++++++------------------- 2 files changed, 53 insertions(+), 32 deletions(-)
arch/Kconfig +16 -6
@@ -404,17 +404,27 @@ config HAVE_NMI_WATCHDOG depends on HAVE_NMI bool help - The arch provides a low level NMI watchdog. It provides - asm/nmi.h, and defines its own watchdog_hardlockup_probe() and - arch_touch_nmi_watchdog(). + The arch provides its own hardlockup detector implementation instead + of the generic perf one. + + Sparc64 defines this variable without HAVE_HARDLOCKUP_DETECTOR_ARCH. + It does _not_ use the command line parameters and sysctl interface + used by generic hardlockup detectors. Instead it is enabled/disabled + by the top-level watchdog interface that is common for both softlockup + and hardlockup detectors. config HAVE_HARDLOCKUP_DETECTOR_ARCH bool select HAVE_NMI_WATCHDOG help - The arch chooses to provide its own hardlockup detector, which is - a superset of the HAVE_NMI_WATCHDOG. It also conforms to config - interfaces and parameters provided by hardlockup detector subsystem. + The arch provides its own hardlockup detector implementation instead + of the generic ones. + + It uses the same command line parameters, and sysctl interface, + as the generic hardlockup detectors. + + HAVE_NMI_WATCHDOG is selected to build the code shared with + the sparc64 specific implementation. config HAVE_PERF_REGS bool
lib/Kconfig.debug +37 -26
101 lines not on this page · raw message
Signature · 1 line
2.35.3
PATCH 5/7 watchdog/sparc64: Rename HAVE_NMI_WATCHDOG to HAVE_HARDLOCKUP_WATCHDOG_SPARC64
In reply to Petr MladekThe configuration variable HAVE_NMI_WATCHDOG has a generic name but it is selected only for SPARC64.
It should _not_ be used in general because it is not integrated with the other hardlockup detectors. Namely, it does not support the hardlockup specific command line parameters and systcl interface. Instead, it is enabled/disabled together with the softlockup detector by the global "watchdog" sysctl.
Rename it to HAVE_HARDLOCKUP_WATCHDOG_SPARC64 to make the special behavior more clear.
Also the variable is set only on sparc64. Move the definition from arch/Kconfig to arch/sparc/Kconfig.debug.
--- arch/Kconfig | 12 ------------ arch/sparc/Kconfig | 2 +- arch/sparc/Kconfig.debug | 12 ++++++++++++ include/linux/nmi.h | 4 ++-- kernel/watchdog.c | 2 +- lib/Kconfig.debug | 5 +---- 6 files changed, 17 insertions(+), 20 deletions(-)
arch/Kconfig +0 -12
@@ -400,18 +400,6 @@ config HAVE_HARDLOCKUP_DETECTOR_PERF The arch chooses to use the generic perf-NMI-based hardlockup detector. Must define HAVE_PERF_EVENTS_NMI. -config HAVE_NMI_WATCHDOG - depends on HAVE_NMI - bool - help - Sparc64 provides its own hardlockup detector implementation instead - of the generic perf one. - - It does _not_ use the command line parameters and sysctl interface - used by generic hardlockup detectors. Instead it is enabled/disabled - by the top-level watchdog interface that is common for both softlockup - and hardlockup detectors. - config HAVE_HARDLOCKUP_DETECTOR_ARCH bool help
arch/sparc/Kconfig +1 -1
@@ -33,7 +33,7 @@ config SPARC select ARCH_WANT_IPC_PARSE_VERSION select GENERIC_PCI_IOMAP select HAS_IOPORT - select HAVE_NMI_WATCHDOG if SPARC64 + select HAVE_HARDLOCKUP_DETECTOR_SPARC64 if SPARC64 select HAVE_CBPF_JIT if SPARC32 select HAVE_EBPF_JIT if SPARC64 select HAVE_DEBUG_BUGVERBOSE
arch/sparc/Kconfig.debug +12 -0
@@ -14,3 +14,15 @@ config FRAME_POINTER bool depends on MCOUNT default y + +config HAVE_HARDLOCKUP_DETECTOR_SPARC64 + depends on HAVE_NMI + bool + help + Sparc64 provides its own hardlockup detector implementation instead + of the generic perf one. + + It does _not_ use the command line parameters and sysctl interface + used by generic hardlockup detectors. Instead it is enabled/disabled + by the top-level watchdog interface that is common for both softlockup + and hardlockup detectors.
include/linux/nmi.h +2 -2
@@ -9,7 +9,7 @@#include <asm/irq.h> /* Arch specific watchdogs might need to share extra watchdog-related APIs. */ -#if defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_ARCH ) || defined(CONFIG_HAVE_NMI_WATCHDOG ) +#if defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_ARCH ) || defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64 )#include <asm/nmi.h> #endif
@@ -92,7 +92,7 @@ static inline void hardlockup_detector_disable(void) {}#endif /* Sparc64 has special implemetantion that is always enabled. */ -#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_NMI_WATCHDOG ) +#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64 )void arch_touch_nmi_watchdog (void );#else static inline void arch_touch_nmi_watchdog (void ) { }
kernel/watchdog.c +1 -1
@@ -29,7 +29,7 @@static DEFINE_MUTEX (watchdog_mutex); -#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_NMI_WATCHDOG ) +#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64 )# define WATCHDOG_HARDLOCKUP_DEFAULT 1#else # define WATCHDOG_HARDLOCKUP_DEFAULT 0
lib/Kconfig.debug +1 -4
@@ -1050,12 +1050,9 @@ config HAVE_HARDLOCKUP_DETECTOR_BUDDY # sparc64: has a custom implementation which is not using the common # hardlockup command line options and sysctl interface. # -# Note that HAVE_NMI_WATCHDOG is set when the sparc64 specific implementation -# is used. -# config HARDLOCKUP_DETECTOR bool "Detect Hard Lockups" - depends on DEBUG_KERNEL && !S390 && !HAVE_NMI_WATCHDOG + depends on DEBUG_KERNEL && !S390 && !HAVE_HARDLOCKUP_DETECTOR_SPARC64 depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY || HAVE_HARDLOCKUP_DETECTOR_ARCH imply HARDLOCKUP_DETECTOR_PERF imply HARDLOCKUP_DETECTOR_BUDDY
Signature · 1 line
2.35.3
PATCH 6/7 watchdog/sparc64: Define HARDLOCKUP_DETECTOR_SPARC64
In reply to Petr MladekThe HAVE_ prefix means that the code could be enabled. Add another variable for HAVE_HARDLOCKUP_DETECTOR_SPARC64 without this prefix. It will be set when it should be built. It will make it compatible with the other hardlockup detectors.
Before, it is far from obvious that the SPARC64 variant is actually used:
$> make ARCH=sparc64 defconfig
$> grep HARDLOCKUP_DETECTOR .configCONFIG_HAVE_HARDLOCKUP_DETECTOR_BUDDY=yCONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64=y
After, it is more clear:
$> make ARCH=sparc64 defconfig
$> grep HARDLOCKUP_DETECTOR .configCONFIG_HAVE_HARDLOCKUP_DETECTOR_BUDDY=yCONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64=yCONFIG_HARDLOCKUP_DETECTOR_SPARC64=y
--- arch/sparc/Kconfig.debug | 10 +++++++++- include/linux/nmi.h | 4 ++-- kernel/watchdog.c | 2 +- lib/Kconfig.debug | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-)
arch/sparc/Kconfig.debug +9 -1
@@ -16,8 +16,9 @@ config FRAME_POINTER default y config HAVE_HARDLOCKUP_DETECTOR_SPARC64 - depends on HAVE_NMI bool + depends on HAVE_NMI + select HARDLOCKUP_DETECTOR_SPARC64 help Sparc64 provides its own hardlockup detector implementation instead of the generic perf one.
@@ -26,3 +27,10 @@ config HAVE_HARDLOCKUP_DETECTOR_SPARC64 used by generic hardlockup detectors. Instead it is enabled/disabled by the top-level watchdog interface that is common for both softlockup and hardlockup detectors. + +config HARDLOCKUP_DETECTOR_SPARC64 + bool + depends on HAVE_HARDLOCKUP_DETECTOR_SPARC64 + + help + The custom hardlockup detector is always built when possible.
include/linux/nmi.h +2 -2
@@ -9,7 +9,7 @@#include <asm/irq.h> /* Arch specific watchdogs might need to share extra watchdog-related APIs. */ -#if defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_ARCH ) || defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64 ) +#if defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_ARCH ) || defined(CONFIG_HARDLOCKUP_DETECTOR_SPARC64 )#include <asm/nmi.h> #endif
@@ -92,7 +92,7 @@ static inline void hardlockup_detector_disable(void) {}#endif /* Sparc64 has special implemetantion that is always enabled. */ -#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64 ) +#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HARDLOCKUP_DETECTOR_SPARC64 )void arch_touch_nmi_watchdog (void );#else static inline void arch_touch_nmi_watchdog (void ) { }
kernel/watchdog.c +1 -1
@@ -29,7 +29,7 @@static DEFINE_MUTEX (watchdog_mutex); -#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64 ) +#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || defined(CONFIG_HARDLOCKUP_DETECTOR_SPARC64 )# define WATCHDOG_HARDLOCKUP_DEFAULT 1#else # define WATCHDOG_HARDLOCKUP_DEFAULT 0
lib/Kconfig.debug +1 -1
@@ -1052,7 +1052,7 @@ config HAVE_HARDLOCKUP_DETECTOR_BUDDY # config HARDLOCKUP_DETECTOR bool "Detect Hard Lockups" - depends on DEBUG_KERNEL && !S390 && !HAVE_HARDLOCKUP_DETECTOR_SPARC64 + depends on DEBUG_KERNEL && !S390 && !HARDLOCKUP_DETECTOR_SPARC64 depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY || HAVE_HARDLOCKUP_DETECTOR_ARCH imply HARDLOCKUP_DETECTOR_PERF imply HARDLOCKUP_DETECTOR_BUDDY
Signature · 1 line
2.35.3
PATCH 3/7 watchdog/hardlockup: Declare arch_touch_nmi_watchdog() only in linux/nmi.h
In reply to Petr Mladekarch_touch_nmi_watchdog() needs a different implementation for various hardlockup detector implementations. And it does nothing when any hardlockup detector is not build at all.
arch_touch_nmi_watchdog() has to be declared in linux/nmi.h. It is done directly in this header file for the perf and buddy detectors. And it is done in the included asm/linux.h for arch specific detectors.
The reason probably is that the arch specific variants build the code using another conditions. For example, powerpc64/sparc64 builds the code when CONFIG_PPC_WATCHDOG is enabled.
Another reason might be that these architectures define more functions in asm/nmi.h anyway.
However the generic code actually knows the information. The config variables HAVE_NMI_WATCHDOG and HAVE_HARDLOCKUP_DETECTOR_ARCH are used to decide whether to build the buddy detector.
In particular, CONFIG_HARDLOCKUP_DETECTOR is set only when a generic or arch-specific hardlockup detector is built. The only exception is sparc64 which ignores the global HARDLOCKUP_DETECTOR switch.
The information about sparc64 is a bit complicated. The hardlockup detector is built there when CONFIG_HAVE_NMI_WATCHDOG is set and CONFIG_HAVE_HARDLOCKUP_DETECTOR_ARCH is not set.
People might wonder whether this change really makes things easier. The motivation is:
+ The current logic in linux/nmi.h is far from obvious. For example, arch_touch_nmi_watchdog() is defined as {} when neither CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER nor CONFIG_HAVE_NMI_WATCHDOG is defined.
+ The change synchronizes the checks in lib/Kconfig.debug and in the generic code.
+ It is a step that will help cleaning HAVE_NMI_WATCHDOG related checks.
The change should not change the existing behavior.
--- arch/powerpc/include/asm/nmi.h | 2 -- arch/sparc/include/asm/nmi.h | 1 - include/linux/nmi.h | 13 ++++++++++--- 3 files changed, 10 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/nmi.h +0 -2
@@ -3,11 +3,9 @@#define _ASM_NMI_H#ifdef CONFIG_PPC_WATCHDOG -extern void arch_touch_nmi_watchdog (void );long soft_nmi_interrupt (struct pt_regs *regs);void watchdog_hardlockup_set_timeout_pct (u64 pct);#else -static inline void arch_touch_nmi_watchdog (void ) {}static inline void watchdog_hardlockup_set_timeout_pct (u64 pct) {}#endif
arch/sparc/include/asm/nmi.h +0 -1
@@ -8,7 +8,6 @@ void nmi_adjust_hz(unsigned int new_hz);extern atomic_t nmi_active; -void arch_touch_nmi_watchdog (void );void start_nmi_watchdog (void *unused);void stop_nmi_watchdog (void *unused);
include/linux/nmi.h +10 -3
@@ -7,6 +7,8 @@#include <linux/sched.h> #include <asm/irq.h> + +/* Arch specific watchdogs might need to share extra watchdog-related APIs. */ #if defined(CONFIG_HAVE_NMI_WATCHDOG )#include <asm/nmi.h> #endif
@@ -89,12 +91,17 @@ extern unsigned int hardlockup_panic;static inline void hardlockup_detector_disable (void ) {}#endif -#if defined(CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER ) +/* Sparc64 has special implemetantion that is always enabled. */ +#if defined(CONFIG_HARDLOCKUP_DETECTOR ) || \ + (defined(CONFIG_HAVE_NMI_WATCHDOG ) && !defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_ARCH ))void arch_touch_nmi_watchdog (void ); +#else +static inline void arch_touch_nmi_watchdog (void ) { } +#endif + +#if defined(CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER )void watchdog_hardlockup_touch_cpu (unsigned int cpu);void watchdog_hardlockup_check (unsigned int cpu,struct pt_regs *regs); -#elif !defined(CONFIG_HAVE_NMI_WATCHDOG ) -static inline void arch_touch_nmi_watchdog (void ) { }#endif #if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF )
Signature · 1 line
2.35.3
PATCH 7/7 watchdog/hardlockup: Define HARDLOCKUP_DETECTOR_ARCH
In reply to Petr MladekThe HAVE_ prefix means that the code could be enabled. Add another variable for HAVE_HARDLOCKUP_DETECTOR_ARCH without this prefix. It will be set when it should be built. It will make it compatible with the other hardlockup detectors.
The change allows to clean up dependencies of PPC_WATCHDOG and HAVE_HARDLOCKUP_DETECTOR_PERF definitions for powerpc.
As a result HAVE_HARDLOCKUP_DETECTOR_PERF has the same dependencies on arm, x86, powerpc architectures.
--- arch/powerpc/Kconfig | 5 ++--- include/linux/nmi.h | 2 +- lib/Kconfig.debug | 9 +++++++++ 3 files changed, 12 insertions(+), 4 deletions(-)
arch/powerpc/Kconfig +2 -3
@@ -90,8 +90,7 @@ config NMI_IPI config PPC_WATCHDOG bool - depends on HARDLOCKUP_DETECTOR - depends on HAVE_HARDLOCKUP_DETECTOR_ARCH + depends on HARDLOCKUP_DETECTOR_ARCH default y help This is a placeholder when the powerpc hardlockup detector
@@ -240,7 +239,7 @@ config PPC select HAVE_GCC_PLUGINS if GCC_VERSION >= 50200 # plugin support on gcc <= 5.1 is buggy on PPC select HAVE_GENERIC_VDSO select HAVE_HARDLOCKUP_DETECTOR_ARCH if PPC_BOOK3S_64 && SMP - select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH + select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI select HAVE_HW_BREAKPOINT if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx) select HAVE_IOREMAP_PROT select HAVE_IRQ_TIME_ACCOUNTING
include/linux/nmi.h +1 -1
@@ -9,7 +9,7 @@#include <asm/irq.h> /* Arch specific watchdogs might need to share extra watchdog-related APIs. */ -#if defined(CONFIG_HAVE_HARDLOCKUP_DETECTOR_ARCH ) || defined(CONFIG_HARDLOCKUP_DETECTOR_SPARC64 ) +#if defined(CONFIG_HARDLOCKUP_DETECTOR_ARCH ) || defined(CONFIG_HARDLOCKUP_DETECTOR_SPARC64 )#include <asm/nmi.h> #endif
lib/Kconfig.debug +9 -0
@@ -1056,6 +1056,7 @@ config HARDLOCKUP_DETECTOR depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY || HAVE_HARDLOCKUP_DETECTOR_ARCH imply HARDLOCKUP_DETECTOR_PERF imply HARDLOCKUP_DETECTOR_BUDDY + imply HARDLOCKUP_DETECTOR_ARCH select LOCKUP_DETECTOR help
@@ -1102,6 +1103,14 @@ config HARDLOCKUP_DETECTOR_BUDDY depends on !HAVE_HARDLOCKUP_DETECTOR_ARCH select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER +config HARDLOCKUP_DETECTOR_ARCH + bool + depends on HARDLOCKUP_DETECTOR + depends on HAVE_HARDLOCKUP_DETECTOR_ARCH + help + The arch-specific implementation of the hardlockup detector is + available. + # # Both the "perf" and "buddy" hardlockup detectors count hrtimer # interrupts. This config enables functions managing this common code.
Signature · 1 line
2.35.3
Re: [PATCH 1/7] watchdog/hardlockup: Sort hardlockup detector related config values a logical way
In reply to Petr MladekHi,
Quoted 37 lines · Petr Mladek
There are four possible variants of hardlockup detectors:
+ buddy: available when SMP is set.
+ perf: available when
HAVE_HARDLOCKUP_DETECTOR_PERFis set.+ arch-specific: available when
HAVE_HARDLOCKUP_DETECTOR_ARCHis set.+ sparc64 special variant: available when
HAVE_NMI_WATCHDOGis set andHAVE_HARDLOCKUP_DETECTOR_ARCHis not set.Only one hardlockup detector can be compiled in. The selection is done using quite complex dependencies between several CONFIG variables. The following patches will try to make it more straightforward.
As a first step, reorder the definitions of the various CONFIG variables. The logical order is:
1. HAVE_* variables define available variants. They are typically defined in the
arch/config files.2.
HARDLOCKUP_DETECTORy/n variable defines whether the hardlockup detector is enabled at all.3.
HARDLOCKUP_DETECTOR_PREFER_BUDDYy/n variable defines whether the buddy detector should be preferred over the perf one. Note that the arch specific variants are always preferred when available.4. HARDLOCKUP_DETECTOR_PERF/BUDDY variables define whether the given detector is enabled in the end.
5.
HAVE_HARDLOCKUP_DETECTOR_NON_ARCHandHARDLOCKUP_DETECTOR_NON_ARCHare temporary variables that are going to be removed in a followup patch.
Quoted 7 lines
The patch just shuffles the definitions. It should not change the existing behavior.
Signed-off-by Petr Mladek <[email protected]>--- lib/Kconfig.debug | 112 +++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 56 deletions(-)
I don't really have any strong opinions, so I'm fine with this. In general I think the ordering I picked tried to match the existing "style" which generally tried to list configs and then select them below. To me the existing style makes more sense when thinking about writing C code without having to put a pile of prototypes at the top of your file: you define things higher in the file and reference them below. For instance, the old style (before any of my patches) had:
config SOFTLOCKUP_DETECTOR:
... blah blah blah ...
config HARDLOCKUP_DETECTOR_PERF:
select SOFTLOCKUP_DETECTOR
config HARDLOCKUP_DETECTOR:
... blah blah blah ...
select LOCKUP_DETECTOR
select HARDLOCKUP_DETECTOR_PERF if HAVE_HARDLOCKUP_DETECTOR_PERF
Your new style seems to be the opposite of that.
-Doug
Re: [PATCH 2/7] watchdog/hardlockup: Make the config checks more straightforward
In reply to Petr MladekHi,
Quoted 6 lines · Petr Mladek
arch/Kconfig +0
-0
arch/Kconfig config HAVE_NMI_WATCHDOG · line 408
Quoted 8 lines
arch/Kconfig +2
-3@@ -404,17 +404,27 @@ config HAVE_NMI_WATCHDOG depends on HAVE_NMI bool help - The arch provides a low level NMI watchdog. It provides - asm/nmi.h, and defines its own watchdog_hardlockup_probe() and - arch_touch_nmi_watchdog(). + The arch provides its own hardlockup detector implementation instead + of the generic perf one.
nit: did you mean to have different wording here compared to HAVE_HARDLOCKUP_DETECTOR_ARCH? Here you say "the generic perf one" and there you say "the generic ones", though it seems like you mean them to be the same.
Quoted 30 lines
arch/Kconfig +14
-3+ + Sparc64 defines this variable without HAVE_HARDLOCKUP_DETECTOR_ARCH. + It does _not_ use the command line parameters and sysctl interface + used by generic hardlockup detectors. Instead it is enabled/disabled + by the top-level watchdog interface that is common for both softlockup + and hardlockup detectors. config HAVE_HARDLOCKUP_DETECTOR_ARCH bool select HAVE_NMI_WATCHDOG help - The arch chooses to provide its own hardlockup detector, which is - a superset of the HAVE_NMI_WATCHDOG. It also conforms to config - interfaces and parameters provided by hardlockup detector subsystem. + The arch provides its own hardlockup detector implementation instead + of the generic ones. + + It uses the same command line parameters, and sysctl interface, + as the generic hardlockup detectors. + + HAVE_NMI_WATCHDOG is selected to build the code shared with + the sparc64 specific implementation. config HAVE_PERF_REGS boollib/Kconfig.debug +0
-0
lib/Kconfig.debug config BOOTPARAM_SOFTLOCKUP_PANIC · line 1041
Quoted 7 lines
lib/Kconfig.debug +4
-0@@ -1035,16 +1035,33 @@ config BOOTPARAM_SOFTLOCKUP_PANIC Say N if unsure. +config HAVE_HARDLOCKUP_DETECTOR_BUDDY + bool + depends on SMP + default y
I think you simplify your life if you also add:
depends on !HAVE_NMI_WATCHDOG
The existing config system has always assumed that no architecture defines both HAVE_HARDLOCKUP_DETECTOR_PERF and HAVE_NMI_WATCHDOG (symbols would have clashed and you would get a link error as two watchdogs try to implement the same weak symbol). If you add the extra dependency to "buddy" as per above, then a few things below fall out. I'll try to point them out below.
lib/Kconfig.debug config BOOTPARAM_SOFTLOCKUP_PANIC · line 1046
Quoted 7 lines
lib/Kconfig.debug +4
-2+ # -# arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard -# lockup detector rather than the perf based detector. +# Global switch whether to build a hardlockup detector at all. It is available +# only when the architecture supports at least one implementation. There are +# two exceptions. The hardlockup detector is newer enabled on:
s/newer/never/
Quoted 6 lines
lib/Kconfig.debug +6
-0+# +# s390: it reported many false positives there +# +# sparc64: has a custom implementation which is not using the common +# hardlockup command line options and sysctl interface. +#
lib/Kconfig.debug config BOOTPARAM_SOFTLOCKUP_PANIC · line 1061
Quoted 10 lines
lib/Kconfig.debug +5
-1+# Note that HAVE_NMI_WATCHDOG is used to distinguish the sparc64 specific +# implementaion. It is automatically enabled also for other arch-specific +# variants which set HAVE_HARDLOCKUP_DETECTOR_ARCH. It makes the check +# of avaialable and supported variants quite tricky. # config HARDLOCKUP_DETECTOR bool "Detect Hard Lockups" depends on DEBUG_KERNEL && !S390 - depends on HAVE_HARDLOCKUP_DETECTOR_NON_ARCH || HAVE_HARDLOCKUP_DETECTOR_ARCH + depends on ((HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY) && !HAVE_NMI_WATCHDOG) || HAVE_HARDLOCKUP_DETECTOR_ARCH
Adding the dependency to buddy (see ablove) would simplify the above to just this:
depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY || HAVE_HARDLOCKUP_DETECTOR_ARCH
As per above, it's simply a responsibility of architectures not to define that they have both "perf" if they have the NMI watchdog, so it's just buddy to worry about.
Quoted 10 lines
lib/Kconfig.debug +2
-1+ imply HARDLOCKUP_DETECTOR_PERF + imply HARDLOCKUP_DETECTOR_BUDDY select LOCKUP_DETECTOR - select HARDLOCKUP_DETECTOR_NON_ARCH if HAVE_HARDLOCKUP_DETECTOR_NON_ARCH help Say Y here to enable the kernel to act as a watchdog to detect@@ -1055,9 +1072,15 @@ config HARDLOCKUP_DETECTOR chance to run. The current stack trace is displayed upon detection and the system will stay locked up.
lib/Kconfig.debug config HARDLOCKUP_DETECTOR · line 1082
Quoted 10 lines
lib/Kconfig.debug +6
-1+# +# Note that arch-specific variants are always preferred. +# config HARDLOCKUP_DETECTOR_PREFER_BUDDY bool "Prefer the buddy CPU hardlockup detector" - depends on HAVE_HARDLOCKUP_DETECTOR_PERF && SMP + depends on HARDLOCKUP_DETECTOR + depends on HAVE_HARDLOCKUP_DETECTOR_PERF && HAVE_HARDLOCKUP_DETECTOR_BUDDY + depends on !HAVE_NMI_WATCHDOG
Can get rid of above "!HAVE_NMI_WATCHDOG" if it's added to HAVE_HARDLOCKUP_DETECTOR_BUDDY.
lib/Kconfig.debug config HARDLOCKUP_DETECTOR · line 1083
Quoted 1 line
lib/Kconfig.debug +1
-0+ default n
I'm pretty sure "default n" isn't needed.
lib/Kconfig.debug config HARDLOCKUP_DETECTOR_PREFER_BUDDY · line 1099
Quoted 11 lines
lib/Kconfig.debug +3
-1help Say Y here to prefer the buddy hardlockup detector over the perf one.@@ -1071,39 +1094,27 @@ config HARDLOCKUP_DETECTOR_PREFER_BUDDY config HARDLOCKUP_DETECTOR_PERF bool - depends on HAVE_HARDLOCKUP_DETECTOR_PERF + depends on HARDLOCKUP_DETECTOR + depends on HAVE_HARDLOCKUP_DETECTOR_PERF && !HARDLOCKUP_DETECTOR_PREFER_BUDDY + depends on !HAVE_NMI_WATCHDOG
We don't really need the "!HAVE_NMI_WATCHDOG". A user wouldn't be able to mess this up and it's up to an architecture not to define both HAVE_HARDLOCKUP_DETECTOR_PERF and HAVE_NMI_WATCHDOG.
lib/Kconfig.debug config HARDLOCKUP_DETECTOR_PREFER_BUDDY · line 1107
Quoted 9 lines
lib/Kconfig.debug +4
-1select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER config HARDLOCKUP_DETECTOR_BUDDY bool - depends on SMP + depends on HARDLOCKUP_DETECTOR + depends on HAVE_HARDLOCKUP_DETECTOR_BUDDY + depends on !HAVE_HARDLOCKUP_DETECTOR_PERF || HARDLOCKUP_DETECTOR_PREFER_BUDDY + depends on !HAVE_NMI_WATCHDOG
Get rid of "!HAVE_NMI_WATCHDOG" and it should be in HAVE_HARDLOCKUP_DETECTOR_BUDDY
Overall, though, I agree that this improves things! Thanks! :-)
Re: [PATCH 5/7] watchdog/sparc64: Rename HAVE_NMI_WATCHDOG to HAVE_HARDLOCKUP_WATCHDOG_SPARC64
In reply to Petr MladekHi,
Quoted 17 lines · Petr Mladek
The configuration variable
HAVE_NMI_WATCHDOGhas a generic name but it is selected only for SPARC64.It should _not_ be used in general because it is not integrated with the other hardlockup detectors. Namely, it does not support the hardlockup specific command line parameters and systcl interface. Instead, it is enabled/disabled together with the softlockup detector by the global "watchdog" sysctl.
Rename it to
HAVE_HARDLOCKUP_WATCHDOG_SPARC64to make the special behavior more clear.Also the variable is set only on sparc64. Move the definition from
arch/Kconfigtoarch/sparc/Kconfig.debug.Signed-off-by Petr Mladek <[email protected]>
Quoted 8 lines
--- arch/Kconfig | 12 ------------ arch/sparc/Kconfig | 2 +- arch/sparc/Kconfig.debug | 12 ++++++++++++ include/linux/nmi.h | 4 ++-- kernel/watchdog.c | 2 +- lib/Kconfig.debug | 5 +---- 6 files changed, 17 insertions(+), 20 deletions(-)
Re: [PATCH 6/7] watchdog/sparc64: Define HARDLOCKUP_DETECTOR_SPARC64
In reply to Petr MladekHi,
Quoted 21 lines · Petr Mladek
The
HAVE_prefix means that the code could be enabled. Add another variable forHAVE_HARDLOCKUP_DETECTOR_SPARC64without this prefix. It will be set when it should be built. It will make it compatible with the other hardlockup detectors.Before, it is far from obvious that the SPARC64 variant is actually used:
$> make ARCH=sparc64 defconfig
$> grepHARDLOCKUP_DETECTOR.configCONFIG_HAVE_HARDLOCKUP_DETECTOR_BUDDY=yCONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64=yAfter, it is more clear:
$> make ARCH=sparc64 defconfig
$> grepHARDLOCKUP_DETECTOR.configCONFIG_HAVE_HARDLOCKUP_DETECTOR_BUDDY=yCONFIG_HAVE_HARDLOCKUP_DETECTOR_SPARC64=yCONFIG_HARDLOCKUP_DETECTOR_SPARC64=y
Quoted 7 lines
Signed-off-by Petr Mladek <[email protected]>--- arch/sparc/Kconfig.debug | 10 +++++++++- include/linux/nmi.h | 4 ++-- kernel/watchdog.c | 2 +- lib/Kconfig.debug | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-)
Re: [PATCH 7/7] watchdog/hardlockup: Define HARDLOCKUP_DETECTOR_ARCH
In reply to Petr MladekHi,
lib/Kconfig.debug config HARDLOCKUP_DETECTOR_BUDDY · line 1112
Quoted 12 lines · Petr Mladek
lib/Kconfig.debug +7
-0@@ -1102,6 +1103,14 @@ config HARDLOCKUP_DETECTOR_BUDDY depends on !HAVE_HARDLOCKUP_DETECTOR_ARCH select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER +config HARDLOCKUP_DETECTOR_ARCH + bool + depends on HARDLOCKUP_DETECTOR + depends on HAVE_HARDLOCKUP_DETECTOR_ARCH + help + The arch-specific implementation of the hardlockup detector is + available.
nit: "is available" makes it sound a bit too much like a "have" version. Maybe "The arch-specific implementation of the hardlockup detector will be used" or something like that?
Otherise:
Hi,
Quoted 6 lines · Petr Mladek
Hi,
this patchset is supposed to replace the last patch in the patchset cleaning up after introducing the buddy detector, see
https://lore.kernel.org/r/20230526184139.10.I821fe7609e57608913fe05abd8f35b343e7a9aae@changeid
I will let Andrew chime in with his preference, but so far I haven't seen him dropping and/or modifying any patches that he's picked up in this series. I see that he's already picked up the patch that you're "replacing". I wonder if it would be easier for him if you just built atop that?
-Doug
Re: [PATCH 3/7] watchdog/hardlockup: Declare arch_touch_nmi_watchdog() only in linux/nmi.h
In reply to Petr MladekHi,
Quoted 4 lines · Petr Mladek
arch_touch_nmi_watchdog()needs a different implementation for various hardlockup detector implementations. And it does nothing when any hardlockup detector is not build at all.
s/build/built/
Quoted 37 lines
arch_touch_nmi_watchdog()has to be declared inlinux/nmi.h. It is done directly in this header file for the perf and buddy detectors. And it is done in the includedasm/linux.hfor arch specific detectors.The reason probably is that the arch specific variants build the code using another conditions. For example, powerpc64/sparc64 builds the code when
CONFIG_PPC_WATCHDOGis enabled.Another reason might be that these architectures define more functions in
asm/nmi.hanyway.However the generic code actually knows the information. The config variables
HAVE_NMI_WATCHDOGandHAVE_HARDLOCKUP_DETECTOR_ARCHare used to decide whether to build the buddy detector.In particular,
CONFIG_HARDLOCKUP_DETECTORis set only when a generic or arch-specific hardlockup detector is built. The only exception is sparc64 which ignores the globalHARDLOCKUP_DETECTORswitch.The information about sparc64 is a bit complicated. The hardlockup detector is built there when
CONFIG_HAVE_NMI_WATCHDOGis set andCONFIG_HAVE_HARDLOCKUP_DETECTOR_ARCHis not set.People might wonder whether this change really makes things easier. The motivation is:
+ The current logic in
linux/nmi.his far from obvious. For example,arch_touch_nmi_watchdog()is defined as {} when neitherCONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMERnorCONFIG_HAVE_NMI_WATCHDOGis defined.+ The change synchronizes the checks in
lib/Kconfig.debugand in the generic code.+ It is a step that will help cleaning
HAVE_NMI_WATCHDOGrelated checks.
Quoted 8 lines
The change should not change the existing behavior.
Signed-off-by Petr Mladek <[email protected]>--- arch/powerpc/include/asm/nmi.h | 2 -- arch/sparc/include/asm/nmi.h | 1 - include/linux/nmi.h | 13 ++++++++++--- 3 files changed, 10 insertions(+), 6 deletions(-)
This looks right and is a nice cleanup.
Re: [PATCH 4/7] watchdog/hardlockup: Enable HAVE_NMI_WATCHDOG only on sparc64
In reply to Petr MladekHi,
arch/Kconfig config HAVE_NMI_WATCHDOG · line 408
Quoted 12 lines · Petr Mladek
arch/Kconfig +1
-1@@ -404,10 +404,9 @@ config HAVE_NMI_WATCHDOG depends on HAVE_NMI bool help - The arch provides its own hardlockup detector implementation instead + Sparc64 provides its own hardlockup detector implementation instead of the generic perf one.
It's a little weird to document generic things with the specifics of the user. The exception, IMO, is when something is deprecated. Personally, it would sound less weird to me to say something like:
The arch provides its own hardlockup detector implementation instead of the generic perf one. This is a deprecated thing to do and kept around until sparc64 provides a full hardlockup implementation or moves to generic code.
Quoted 11 lines
lib/Kconfig.debug +0
-3@@ -1050,15 +1050,13 @@ config HAVE_HARDLOCKUP_DETECTOR_BUDDY # sparc64: has a custom implementation which is not using the common # hardlockup command line options and sysctl interface. # -# Note that HAVE_NMI_WATCHDOG is used to distinguish the sparc64 specific -# implementaion. It is automatically enabled also for other arch-specific -# variants which set HAVE_HARDLOCKUP_DETECTOR_ARCH. It makes the check
lib/Kconfig.debug config HAVE_HARDLOCKUP_DETECTOR_BUDDY · line 1059
Quoted 10 lines
lib/Kconfig.debug +4
-3-# of avaialable and supported variants quite tricky. +# Note that HAVE_NMI_WATCHDOG is set when the sparc64 specific implementation +# is used. # config HARDLOCKUP_DETECTOR bool "Detect Hard Lockups" - depends on DEBUG_KERNEL && !S390 - depends on ((HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY) && !HAVE_NMI_WATCHDOG) || HAVE_HARDLOCKUP_DETECTOR_ARCH + depends on DEBUG_KERNEL && !S390 && !HAVE_NMI_WATCHDOG + depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY || HAVE_HARDLOCKUP_DETECTOR_ARCH
If you add the "!HAVE_NMI_WATCHDOG" as a dependency to HAVE_HARDLOCKUP_DETECTOR_BUDDY, as discussed in a previous patch, you can skip adding it here.
lib/Kconfig.debug config HARDLOCKUP_DETECTOR_PREFER_BUDDY · line 1080
Quoted 9 lines
lib/Kconfig.debug +1
-1imply HARDLOCKUP_DETECTOR_PERF imply HARDLOCKUP_DETECTOR_BUDDY select LOCKUP_DETECTOR@@ -1079,7 +1077,7 @@ config HARDLOCKUP_DETECTOR_PREFER_BUDDY bool "Prefer the buddy CPU hardlockup detector" depends on HARDLOCKUP_DETECTOR depends on HAVE_HARDLOCKUP_DETECTOR_PERF && HAVE_HARDLOCKUP_DETECTOR_BUDDY - depends on !HAVE_NMI_WATCHDOG + depends on !HAVE_HARLOCKUP_DETECTOR_ARCH
Don't need this. Architectures never are allowed to define HAVE_HARDLOCKUP_DETECTOR_PERF and HAVE_HARLOCKUP_DETECTOR_ARCH
lib/Kconfig.debug config HARDLOCKUP_DETECTOR_PERF · line 1097
Quoted 9 lines
lib/Kconfig.debug +1
-1default n help Say Y here to prefer the buddy hardlockup detector over the perf one.@@ -1096,7 +1094,7 @@ config HARDLOCKUP_DETECTOR_PERF bool depends on HARDLOCKUP_DETECTOR depends on HAVE_HARDLOCKUP_DETECTOR_PERF && !HARDLOCKUP_DETECTOR_PREFER_BUDDY - depends on !HAVE_NMI_WATCHDOG + depends on !HAVE_HARDLOCKUP_DETECTOR_ARCH
Similarly, don't need this.
lib/Kconfig.debug config HARDLOCKUP_DETECTOR_BUDDY · line 1105
Quoted 9 lines
lib/Kconfig.debug +1
-1select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER config HARDLOCKUP_DETECTOR_BUDDY@@ -1104,7 +1102,7 @@ config HARDLOCKUP_DETECTOR_BUDDY depends on HARDLOCKUP_DETECTOR depends on HAVE_HARDLOCKUP_DETECTOR_BUDDY depends on !HAVE_HARDLOCKUP_DETECTOR_PERF || HARDLOCKUP_DETECTOR_PREFER_BUDDY - depends on !HAVE_NMI_WATCHDOG + depends on !HAVE_HARDLOCKUP_DETECTOR_ARCH
Similarly, don't need this.
In general I don't object to splitting out HAVE_NMI_WATCHDOG from HAVE_HARDLOCKUP_DETECTOR_ARCH.
Re: [PATCH 1/7] watchdog/hardlockup: Sort hardlockup detector related config values a logical way
In reply to Doug AndersonQuoted 29 lines · Doug Anderson
Hi,
Quoted 18 lines · Petr Mladek
Only one hardlockup detector can be compiled in. The selection is done using quite complex dependencies between several CONFIG variables. The following patches will try to make it more straightforward.
As a first step, reorder the definitions of the various CONFIG variables. The logical order is:
1. HAVE_* variables define available variants. They are typically defined in the
arch/config files.2.
HARDLOCKUP_DETECTORy/n variable defines whether the hardlockup detector is enabled at all.3.
HARDLOCKUP_DETECTOR_PREFER_BUDDYy/n variable defines whether the buddy detector should be preferred over the perf one. Note that the arch specific variants are always preferred when available.Quoted 7 lines
4. HARDLOCKUP_DETECTOR_PERF/BUDDY variables define whether the given detector is enabled in the end.
5.
HAVE_HARDLOCKUP_DETECTOR_NON_ARCHandHARDLOCKUP_DETECTOR_NON_ARCHare temporary variables that are going to be removed in a followup patch.
Quoted 5 lines
I don't really have any strong opinions, so I'm fine with this. In general I think the ordering I picked tried to match the existing "style" which generally tried to list configs and then select them below. To me the existing style makes more sense when thinking about writing C code
I know. My motivation was the following:
1. Kconfig is not C. My view is that it is more like a menu. There is a top level item. If the top level is enabled then there is a submenu with a more detailed selection of various variants and options.
2. The current logic is quite complicated from my POV. And it was even before your patchset. For example, HAVE_HARDLOCKUP_DETECTOR_BUDDY is defined as:
config HAVE_HARDLOCKUP_DETECTOR_BUDDY
bool
depends on SMP
default y
One would expect that it would be enabled on SMP system. But the final value depends on many other variables which are defined using relatively complex conditions, especially HARDLOCKUP_DETECTOR, HAVE_HARDLOCKUP_DETECTOR_NON_ARCH, and HARDLOCKUP_DETECTOR_NON_ARCH.
Understanding the logic is even more complicated because Kconfig is not indexed by cscope.
Important: The logic used at the end of the patchset actually
follows the C style. It defines how the various variables depend on each other from top to bottom.
Quoted 3 lines
config
SOFTLOCKUP_DETECTOR:
... blah blah blah ...
This one is actually defined in the menu-like order:
config SOFTLOCKUP_DETECTOR
config BOOTPARAM_SOFTLOCKUP_PANIC
depends on SOFTLOCKUP_DETECTOR
It is because the custom option depends on the top level one. This is exactly what I would like to achieve with HARDLOCKUP variables in this patchset.
Best Regards,
Petr
Re: [PATCH 2/7] watchdog/hardlockup: Make the config checks more straightforward
In reply to Doug AndersonQuoted 14 lines · Doug Anderson
Hi,
Quoted 11 lines · Petr Mladek
arch/Kconfig +0
-2@@ -404,17 +404,27 @@ config HAVE_NMI_WATCHDOG depends on HAVE_NMI bool help - The arch provides a low level NMI watchdog. It provides - asm/nmi.h, and defines its own watchdog_hardlockup_probe() and
Quoted 8 lines
arch/Kconfig config HAVE_NMI_WATCHDOG · line 408
Quoted 3 lines
arch/Kconfig +2
-1- arch_touch_nmi_watchdog(). + The arch provides its own hardlockup detector implementation instead + of the generic perf one.nit: did you mean to have different wording here compared to
HAVE_HARDLOCKUP_DETECTOR_ARCH? Here you say "the generic perf one" and there you say "the generic ones", though it seems like you mean them to be the same.
Good point, I'll fix it in v2.
Quoted 15 lines
lib/Kconfig.debug config BOOTPARAM_SOFTLOCKUP_PANIC · line 1041
Quoted 12 lines
lib/Kconfig.debug +4
-0@@ -1035,16 +1035,33 @@ config BOOTPARAM_SOFTLOCKUP_PANIC Say N if unsure. +config HAVE_HARDLOCKUP_DETECTOR_BUDDY + bool + depends on SMP + default yI think you simplify your life if you also add:
Quoted 8 lines
depends on !HAVE_NMI_WATCHDOG
The existing config system has always assumed that no architecture defines both
HAVE_HARDLOCKUP_DETECTOR_PERFandHAVE_NMI_WATCHDOG(symbols would have clashed and you would get a link error as two watchdogs try to implement the same weak symbol). If you add the extra dependency to "buddy" as per above, then a few things below fall out. I'll try to point them out below.
My aim is to have two variables with and without HAVE_* prefix for each variant. They already existed for perf:
+ HAVE_HARDLOCKUP_DETECTOR_PERF means that it is supported by the arch.
+ HARDLOCKUP_DETECTOR_PERF means that it will really be built.
1. It will make it clear what variants are available on the give system. And it will make it clear what variant is used in the end.
2. It allows to add the dependecy on the global switch HARDLOCKUP_DETECTOR. It makes it clear that the detector could be disabled by this switch. Also it actually allows to use both top-bottom logic and C-like definition ordering.
Quoted 10 lines
lib/Kconfig.debug config BOOTPARAM_SOFTLOCKUP_PANIC · line 1046
Quoted 8 lines
lib/Kconfig.debug +4
-2+ # -# arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard -# lockup detector rather than the perf based detector. +# Global switch whether to build a hardlockup detector at all. It is available +# only when the architecture supports at least one implementation. There are +# two exceptions. The hardlockup detector is newer enabled on:s/newer/never/
Great catch. Will fix in v2.
Quoted 20 lines
Quoted 6 lines
lib/Kconfig.debug +6
-0+# +# s390: it reported many false positives there +# +# sparc64: has a custom implementation which is not using the common +# hardlockup command line options and sysctl interface. +#lib/Kconfig.debug config BOOTPARAM_SOFTLOCKUP_PANIC · line 1061
Quoted 10 lines
lib/Kconfig.debug +5
-1+# Note that HAVE_NMI_WATCHDOG is used to distinguish the sparc64 specific +# implementaion. It is automatically enabled also for other arch-specific +# variants which set HAVE_HARDLOCKUP_DETECTOR_ARCH. It makes the check +# of avaialable and supported variants quite tricky. # config HARDLOCKUP_DETECTOR bool "Detect Hard Lockups" depends on DEBUG_KERNEL && !S390 - depends on HAVE_HARDLOCKUP_DETECTOR_NON_ARCH || HAVE_HARDLOCKUP_DETECTOR_ARCH + depends on ((HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY) && !HAVE_NMI_WATCHDOG) || HAVE_HARDLOCKUP_DETECTOR_ARCHAdding the dependency to buddy (see ablove) would simplify the above to just this:
Quoted 2 lines
depends on
HAVE_HARDLOCKUP_DETECTOR_PERF||HAVE_HARDLOCKUP_DETECTOR_BUDDY||HAVE_HARDLOCKUP_DETECTOR_ARCH
This is exactly what I do not want. It would just move the check somewhere else. But it would make the logic harder to understand. Especially when the related definitions could not be found by cscope.
Quoted 3 lines
As per above, it's simply a responsibility of architectures not to define that they have both "perf" if they have the NMI watchdog, so it's just buddy to worry about.
Where is this documented, please?
Is it safe to assume this?
I would personally prefer to ensure this by the config check. It is even better than documentation because nobody reads documentation ;-)
It took me long time to understand all the dependencies and possibilities. My motivation is that neither me nor others would need to absolve the same adventure in the future.
Quoted 12 lines
Quoted 12 lines
lib/Kconfig.debug +2
-1+ imply HARDLOCKUP_DETECTOR_PERF + imply HARDLOCKUP_DETECTOR_BUDDY select LOCKUP_DETECTOR - select HARDLOCKUP_DETECTOR_NON_ARCH if HAVE_HARDLOCKUP_DETECTOR_NON_ARCH help Say Y here to enable the kernel to act as a watchdog to detect@@ -1055,9 +1072,15 @@ config HARDLOCKUP_DETECTOR chance to run. The current stack trace is displayed upon detection and the system will stay locked up.
Quoted 12 lines
lib/Kconfig.debug config HARDLOCKUP_DETECTOR · line 1082
Quoted 9 lines
lib/Kconfig.debug +6
-1+# +# Note that arch-specific variants are always preferred. +# config HARDLOCKUP_DETECTOR_PREFER_BUDDY bool "Prefer the buddy CPU hardlockup detector" - depends on HAVE_HARDLOCKUP_DETECTOR_PERF && SMP + depends on HARDLOCKUP_DETECTOR + depends on HAVE_HARDLOCKUP_DETECTOR_PERF && HAVE_HARDLOCKUP_DETECTOR_BUDDY + depends on !HAVE_NMI_WATCHDOGCan get rid of above "!HAVE_NMI_WATCHDOG" if it's added to
HAVE_HARDLOCKUP_DETECTOR_BUDDY.
I would prefer to keep it hear to make it clear on the first look.
Quoted 3 lines
lib/Kconfig.debug config HARDLOCKUP_DETECTOR · line 1083
Quoted 1 line
lib/Kconfig.debug +1
-0+ default nI'm pretty sure "default n" isn't needed.
I'll try and fix in v2.
Quoted 6 lines
Quoted 6 lines
lib/Kconfig.debug +0
-0help Say Y here to prefer the buddy hardlockup detector over the perf one.@@ -1071,39 +1094,27 @@ config HARDLOCKUP_DETECTOR_PREFER_BUDDY
Quoted 10 lines
lib/Kconfig.debug config HARDLOCKUP_DETECTOR_PREFER_BUDDY · line 1099
Quoted 6 lines
lib/Kconfig.debug +3
-1config HARDLOCKUP_DETECTOR_PERF bool - depends on HAVE_HARDLOCKUP_DETECTOR_PERF + depends on HARDLOCKUP_DETECTOR + depends on HAVE_HARDLOCKUP_DETECTOR_PERF && !HARDLOCKUP_DETECTOR_PREFER_BUDDY + depends on !HAVE_NMI_WATCHDOGWe don't really need the "!HAVE_NMI_WATCHDOG". A user wouldn't be able to mess this up and it's up to an architecture not to define both
HAVE_HARDLOCKUP_DETECTOR_PERFandHAVE_NMI_WATCHDOG.
This is an assumption that only few people knows. I would prefer to enforce this by the check.
Quoted 1 line
Overall, though, I agree that this improves things! Thanks! :-)
Thanks a lot for the review. I did my best and I got lost many times ;-)
Best Regards,
Petr
Re: [PATCH 3/7] watchdog/hardlockup: Declare arch_touch_nmi_watchdog() only in linux/nmi.h
In reply to Doug AndersonQuoted 9 lines · Doug Anderson
Hi,
Quoted 4 lines · Petr Mladek
arch_touch_nmi_watchdog()needs a different implementation for various hardlockup detector implementations. And it does nothing when any hardlockup detector is not build at all.s/build/built/
Will fix in v2.
Quoted 4 lines
This looks right and is a nice cleanup.
Reviewed-by Douglas Anderson <[email protected]>
Thanks a lot.
Best Regards,
Petr
Re: [PATCH 4/7] watchdog/hardlockup: Enable HAVE_NMI_WATCHDOG only on sparc64
In reply to Doug AndersonQuoted 4 lines · Doug Anderson
Hi,
Quoted 1 line · Petr Mladek
Quoted 15 lines
arch/Kconfig config HAVE_NMI_WATCHDOG · line 408
Quoted 11 lines
arch/Kconfig +1
-1@@ -404,10 +404,9 @@ config HAVE_NMI_WATCHDOG depends on HAVE_NMI bool help - The arch provides its own hardlockup detector implementation instead + Sparc64 provides its own hardlockup detector implementation instead of the generic perf one.It's a little weird to document generic things with the specifics of the user. The exception, IMO, is when something is deprecated. Personally, it would sound less weird to me to say something like:
Or I could replace "The arch" by "Sparc64" in the 5th patch which renames the variable to HAVE_HARDLOCKUP_DETECTOR_SPARC64. It will not longer be a generic thing...
Or I could squash the two patches. I did not want to do too many changes at the same time. But it might actually make sense to do this in one step.
Quoted 18 lines
Quoted 18 lines
lib/Kconfig.debug +2
-4@@ -1050,15 +1050,13 @@ config HAVE_HARDLOCKUP_DETECTOR_BUDDY # sparc64: has a custom implementation which is not using the common # hardlockup command line options and sysctl interface. # -# Note that HAVE_NMI_WATCHDOG is used to distinguish the sparc64 specific -# implementaion. It is automatically enabled also for other arch-specific -# variants which set HAVE_HARDLOCKUP_DETECTOR_ARCH. It makes the check -# of avaialable and supported variants quite tricky. +# Note that HAVE_NMI_WATCHDOG is set when the sparc64 specific implementation +# is used. # config HARDLOCKUP_DETECTOR bool "Detect Hard Lockups"
Quoted 8 lines
lib/Kconfig.debug config HAVE_HARDLOCKUP_DETECTOR_BUDDY · line 1059
Quoted 4 lines
lib/Kconfig.debug +2
-2- depends on DEBUG_KERNEL && !S390 - depends on ((HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY) && !HAVE_NMI_WATCHDOG) || HAVE_HARDLOCKUP_DETECTOR_ARCH + depends on DEBUG_KERNEL && !S390 && !HAVE_NMI_WATCHDOG + depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY || HAVE_HARDLOCKUP_DETECTOR_ARCHIf you add the "!HAVE_NMI_WATCHDOG" as a dependency to
HAVE_HARDLOCKUP_DETECTOR_BUDDY, as discussed in a previous patch, you can skip adding it here.
It it related to the 2nd patch. Let's discuss it there.
Quoted 13 lines
lib/Kconfig.debug config HARDLOCKUP_DETECTOR_PREFER_BUDDY · line 1080
Quoted 10 lines
lib/Kconfig.debug +1
-1imply HARDLOCKUP_DETECTOR_PERF imply HARDLOCKUP_DETECTOR_BUDDY select LOCKUP_DETECTOR@@ -1079,7 +1077,7 @@ config HARDLOCKUP_DETECTOR_PREFER_BUDDY bool "Prefer the buddy CPU hardlockup detector" depends on HARDLOCKUP_DETECTOR depends on HAVE_HARDLOCKUP_DETECTOR_PERF && HAVE_HARDLOCKUP_DETECTOR_BUDDY - depends on !HAVE_NMI_WATCHDOG + depends on !HAVE_HARLOCKUP_DETECTOR_ARCHDon't need this. Architectures never are allowed to define
HAVE_HARDLOCKUP_DETECTOR_PERFandHAVE_HARLOCKUP_DETECTOR_ARCH
Same here...
Best Regards,
Petr
Re: [PATCH 7/7] watchdog/hardlockup: Define HARDLOCKUP_DETECTOR_ARCH
In reply to Doug AndersonQuoted 8 lines · Doug Anderson
Hi,
Quoted 5 lines · Petr Mladek
lib/Kconfig.debug +0
-0@@ -1102,6 +1103,14 @@ config HARDLOCKUP_DETECTOR_BUDDY depends on !HAVE_HARDLOCKUP_DETECTOR_ARCH select HARDLOCKUP_DETECTOR_COUNTS_HRTIMER
Quoted 11 lines
lib/Kconfig.debug config HARDLOCKUP_DETECTOR_BUDDY · line 1112
Quoted 7 lines
lib/Kconfig.debug +7
-0+config HARDLOCKUP_DETECTOR_ARCH + bool + depends on HARDLOCKUP_DETECTOR + depends on HAVE_HARDLOCKUP_DETECTOR_ARCH + help + The arch-specific implementation of the hardlockup detector is + available.nit: "is available" makes it sound a bit too much like a "have" version. Maybe "The arch-specific implementation of the hardlockup detector will be used" or something like that?
Makes sense. Will do this change in v2.
Quoted 3 lines
Otherise:
Reviewed-by Douglas Anderson <[email protected]>
Thanks,
Petr
Re: [PATCH 2/7] watchdog/hardlockup: Make the config checks more straightforward
In reply to Petr MladekHi,
Quoted 7 lines · Petr Mladek
Quoted 7 lines
Quoted 6 lines
config
HARDLOCKUP_DETECTOR
bool "Detect Hard Lockups"
depends onDEBUG_KERNEL&& !S390lib/Kconfig.debug +1
-1- depends on HAVE_HARDLOCKUP_DETECTOR_NON_ARCH || HAVE_HARDLOCKUP_DETECTOR_ARCH + depends on ((HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY) && !HAVE_NMI_WATCHDOG) || HAVE_HARDLOCKUP_DETECTOR_ARCH
Quoted 8 lines
Quoted 5 lines
Adding the dependency to buddy (see ablove) would simplify the above to just this:
depends on
HAVE_HARDLOCKUP_DETECTOR_PERF||HAVE_HARDLOCKUP_DETECTOR_BUDDY||HAVE_HARDLOCKUP_DETECTOR_ARCHThis is exactly what I do not want. It would just move the check somewhere else. But it would make the logic harder to understand.
Hmmm. To me, it felt easier to understand by moving this into the "HAVE_HARDLOCKUP_DETECTOR_BUDDY". To me it was pretty easy to say "if an architecture defined its own arch-specific watchdog then buddy can't be enabled" and that felt like it fit cleanly within the "HAVE_HARDLOCKUP_DETECTOR_BUDDY" definition. It got rid of _a lot_ of other special cases / checks elsewhere and felt quite a bit cleaner to me. I only had to think about the conflict between the "buddy" and "nmi" watchdogs once when I understood "HAVE_HARDLOCKUP_DETECTOR_BUDDY".
Quoted 6 lines
Quoted 3 lines
As per above, it's simply a responsibility of architectures not to define that they have both "perf" if they have the NMI watchdog, so it's just buddy to worry about.
Where is this documented, please?
Is it safe to assume this?
It's not well documented and I agree that it could be improved. Right now, HAVE_NMI_WATCHDOG is documented to say that the architecture "defines its own arch_touch_nmi_watchdog()". Looking before my patches, you can see that "kernel/watchdog_hld.c" (the "perf" detector code) unconditionally defines arch_touch_nmi_watchdog(). That would give you a linker error.
Quoted 3 lines
I would personally prefer to ensure this by the config check. It is even better than documentation because nobody reads documentation ;-)
Sure. IMO this should be documented as close as possible to the root of the problem. Make "HAVE_NMI_WATCHDOG" depend on "!HAVE_HARDLOCKUP_DETECTOR_PERF". That expresses that an architecture is not allowed to declare that it has both.
Re: [PATCH 2/7] watchdog/hardlockup: Make the config checks more straightforward
Quoted 19 lines · Doug Anderson
Hi,
Quoted 7 lines · Petr Mladek
Quoted 7 lines
Quoted 6 lines
config
HARDLOCKUP_DETECTOR
bool "Detect Hard Lockups"
depends onDEBUG_KERNEL&& !S390lib/Kconfig.debug +1
-1- depends on HAVE_HARDLOCKUP_DETECTOR_NON_ARCH || HAVE_HARDLOCKUP_DETECTOR_ARCH + depends on ((HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_BUDDY) && !HAVE_NMI_WATCHDOG) || HAVE_HARDLOCKUP_DETECTOR_ARCHQuoted 8 lines
Quoted 5 lines
Adding the dependency to buddy (see ablove) would simplify the above to just this:
depends on
HAVE_HARDLOCKUP_DETECTOR_PERF||HAVE_HARDLOCKUP_DETECTOR_BUDDY||HAVE_HARDLOCKUP_DETECTOR_ARCHThis is exactly what I do not want. It would just move the check somewhere else. But it would make the logic harder to understand.
Quoted 9 lines
Hmmm. To me, it felt easier to understand by moving this into the "
HAVE_HARDLOCKUP_DETECTOR_BUDDY". To me it was pretty easy to say "if an architecture defined its own arch-specific watchdog then buddy can't be enabled" and that felt like it fit cleanly within the "HAVE_HARDLOCKUP_DETECTOR_BUDDY" definition. It got rid of _alot_of other special cases / checks elsewhere and felt quite a bit cleaner to me. I only had to think about the conflict between the "buddy" and "nmi" watchdogs once when I understood "HAVE_HARDLOCKUP_DETECTOR_BUDDY".
I see. My problem with this approach was that the dependencies between the 4 alternative implementations were too distributed. It was necessary read many definitions to understand what was possible and what was not possible. And it is even more complicated when cscope does not support Kconfig.
Also the above solves the buddy detector which is global.
The same conflict has PERF which has arch-specific dependencies. Maybe, it can be disabled by a conflict in the arch/Kconfig. But then the PERF dependencies would be split into 3 config
files: arch/Kconfig, lib/Kconfig.debug, arch/Kconfig/.
Anyway, HAVE_*_BUDDY and HAVE_*_PERF should behave the same. Both should either explicitly conflict with HAVE_*_ARCH and HAVE_NMI_WATCHDOG. Or they both should be enabled when they are supported by the architecture and just ignored when choosing the final implementation.
My wish was to have consistent naming:
+ HAVE_HARDLOCKUP_DETECTOR_<impl> set when the the architecture supports the particular implementation.
+ HARDLOCKUP_DETECTOR_<impl> set when the implementation will be used (built).
Step aside:
It seems that we have entered into a bike shedding mode. The following questions come to my mind:
1. Does this patchset improve the current state?
2. Maybe, it is not black&white. Is it possible to summarize what exactly got better and what got worse?
Maybe, there is no need to do bike-shedding about every step if the final result is reasonable and the steps are not completely wrong.
I just followed my intuition and tried to do some changes step by step. I got lost many times so maybe the steps are not ideal. Anyway, the steps helped me to understand the logic and stay reasonably confident that they did not change the behavior.
I could rework the patchset. But I first need to know what exactly is bad in the result. And eventually if there is more logical way how to end there.
Best Regards,
Petr
Re: [PATCH 2/7] watchdog/hardlockup: Make the config checks more straightforward
Hi,
Quoted 19 lines · Petr Mladek
It seems that we have entered into a bike shedding mode. The following questions come to my mind:
1. Does this patchset improve the current state?
2. Maybe, it is not black&white. Is it possible to summarize what exactly got better and what got worse?
Maybe, there is no need to do bike-shedding about every step if the final result is reasonable and the steps are not completely wrong.
I just followed my intuition and tried to do some changes step by step. I got lost many times so maybe the steps are not ideal. Anyway, the steps helped me to understand the logic and stay reasonably confident that they did not change the behavior.
Quoted 3 lines
I could rework the patchset. But I first need to know what exactly is bad in the result. And eventually if there is more logical way how to end there.
Sure. I still feel like the end result of the CONFIG options after your whole patchset is easier to understand / cleaner by adjusting the dependencies as I have suggested. That being said, I agree that it is the type of thing that can be more a matter of personal preference. I do agree that, even if you don't take my suggestion of adjusting the dependencies, the end result of your patchset still makes things better than they were.
...so if you really feel strongly that things are more understandable with the dependencies specified as you have, I won't stand in the way. I still think you need a v2, though, just to address other nits.
-Doug