Skip to content

Commit 0c68bda

Browse files
pmladekakpm00
authored andcommitted
watchdog/hardlockup: declare arch_touch_nmi_watchdog() only in linux/nmi.h
arch_touch_nmi_watchdog() needs a different implementation for various hardlockup detector implementations. And it does nothing when any hardlockup detector is not built at all. arch_touch_nmi_watchdog() is declared via linux/nmi.h. And it must be defined as an empty function when there is no hardlockup detector. 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 when the function will be implemented. It happens when some full featured or the sparc64-specific hardlockup detector is built. In particular, CONFIG_HARDLOCKUP_DETECTOR can be enabled only when a generic or arch-specific full featured hardlockup detector is available. The only exception is sparc64 which can be built even when the global HARDLOCKUP_DETECTOR switch is disabled. 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. Link: https://lkml.kernel.org/r/20230616150618.6073-4-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 1356d0b commit 0c68bda

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

arch/powerpc/include/asm/nmi.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
#define _ASM_NMI_H
44

55
#ifdef CONFIG_PPC_WATCHDOG
6-
extern void arch_touch_nmi_watchdog(void);
76
long soft_nmi_interrupt(struct pt_regs *regs);
87
void watchdog_hardlockup_set_timeout_pct(u64 pct);
98
#else
10-
static inline void arch_touch_nmi_watchdog(void) {}
119
static inline void watchdog_hardlockup_set_timeout_pct(u64 pct) {}
1210
#endif
1311

arch/sparc/include/asm/nmi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ void nmi_adjust_hz(unsigned int new_hz);
88

99
extern atomic_t nmi_active;
1010

11-
void arch_touch_nmi_watchdog(void);
1211
void start_nmi_watchdog(void *unused);
1312
void stop_nmi_watchdog(void *unused);
1413

include/linux/nmi.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include <linux/sched.h>
99
#include <asm/irq.h>
10+
11+
/* Arch specific watchdogs might need to share extra watchdog-related APIs. */
1012
#if defined(CONFIG_HAVE_NMI_WATCHDOG)
1113
#include <asm/nmi.h>
1214
#endif
@@ -87,12 +89,17 @@ extern unsigned int hardlockup_panic;
8789
static inline void hardlockup_detector_disable(void) {}
8890
#endif
8991

90-
#if defined(CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER)
92+
/* 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))
9195
void arch_touch_nmi_watchdog(void);
96+
#else
97+
static inline void arch_touch_nmi_watchdog(void) { }
98+
#endif
99+
100+
#if defined(CONFIG_HARDLOCKUP_DETECTOR_COUNTS_HRTIMER)
92101
void watchdog_hardlockup_touch_cpu(unsigned int cpu);
93102
void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs);
94-
#elif !defined(CONFIG_HAVE_NMI_WATCHDOG)
95-
static inline void arch_touch_nmi_watchdog(void) { }
96103
#endif
97104

98105
#if defined(CONFIG_HARDLOCKUP_DETECTOR_PERF)

0 commit comments

Comments
 (0)