Skip to content

Commit f2e0cff

Browse files
npiggintorvalds
authored andcommitted
kernel/watchdog: introduce arch_touch_nmi_watchdog()
For architectures that define HAVE_NMI_WATCHDOG, instead of having them provide the complete touch_nmi_watchdog() function, just have them provide arch_touch_nmi_watchdog(). This gives the generic code more flexibility in implementing this function, and arch implementations don't miss out on touching the softlockup watchdog or other generic details. Link: http://lkml.kernel.org/r/20170616065715.18390-3-npiggin@gmail.com Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Reviewed-by: Don Zickus <dzickus@redhat.com> Reviewed-by: Babu Moger <babu.moger@oracle.com> Tested-by: Babu Moger <babu.moger@oracle.com> [sparc] Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 24bb446 commit f2e0cff

File tree

9 files changed

+31
-24
lines changed

9 files changed

+31
-24
lines changed

arch/blackfin/include/asm/nmi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99

1010
#include <linux/nmi.h>
1111

12+
extern void arch_touch_nmi_watchdog(void);
13+
1214
#endif

arch/blackfin/kernel/nmi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static int __init init_nmi_wdt(void)
190190
}
191191
device_initcall(init_nmi_wdt);
192192

193-
void touch_nmi_watchdog(void)
193+
void arch_touch_nmi_watchdog(void)
194194
{
195195
atomic_set(&nmi_touched[smp_processor_id()], 1);
196196
}

arch/mn10300/include/asm/nmi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@
1111
#ifndef _ASM_NMI_H
1212
#define _ASM_NMI_H
1313

14+
extern void arch_touch_nmi_watchdog(void);
15+
1416
#endif /* _ASM_NMI_H */

arch/mn10300/kernel/mn10300-watchdog-low.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ watchdog_handler:
5050
# we can't inline it)
5151
#
5252
###############################################################################
53-
.globl touch_nmi_watchdog
54-
.type touch_nmi_watchdog,@function
55-
touch_nmi_watchdog:
53+
.globl arch_touch_nmi_watchdog
54+
.type arch_touch_nmi_watchdog,@function
55+
arch_touch_nmi_watchdog:
5656
clr d0
5757
clr d1
5858
mov watchdog_alert_counter, a0
@@ -63,4 +63,4 @@ touch_nmi_watchdog:
6363
lne
6464
ret [],0
6565

66-
.size touch_nmi_watchdog,.-touch_nmi_watchdog
66+
.size arch_touch_nmi_watchdog,.-arch_touch_nmi_watchdog

arch/mn10300/kernel/mn10300-watchdog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static unsigned int watchdog;
3131
static unsigned int watchdog_hz = 1;
3232
unsigned int watchdog_alert_counter[NR_CPUS];
3333

34-
EXPORT_SYMBOL(touch_nmi_watchdog);
34+
EXPORT_SYMBOL(arch_touch_nmi_watchdog);
3535

3636
/*
3737
* the best way to detect whether a CPU has a 'hard lockup' problem

arch/sparc/include/asm/nmi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ void nmi_adjust_hz(unsigned int new_hz);
77

88
extern atomic_t nmi_active;
99

10+
void arch_touch_nmi_watchdog(void);
1011
void start_nmi_watchdog(void *unused);
1112
void stop_nmi_watchdog(void *unused);
1213

arch/sparc/kernel/nmi.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static DEFINE_PER_CPU(unsigned int, last_irq_sum);
5151
static DEFINE_PER_CPU(long, alert_counter);
5252
static DEFINE_PER_CPU(int, nmi_touch);
5353

54-
void touch_nmi_watchdog(void)
54+
void arch_touch_nmi_watchdog(void)
5555
{
5656
if (atomic_read(&nmi_active)) {
5757
int cpu;
@@ -61,10 +61,8 @@ void touch_nmi_watchdog(void)
6161
per_cpu(nmi_touch, cpu) = 1;
6262
}
6363
}
64-
65-
touch_softlockup_watchdog();
6664
}
67-
EXPORT_SYMBOL(touch_nmi_watchdog);
65+
EXPORT_SYMBOL(arch_touch_nmi_watchdog);
6866

6967
static void die_nmi(const char *str, struct pt_regs *regs, int do_panic)
7068
{

include/linux/nmi.h

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
#include <linux/sched.h>
88
#include <asm/irq.h>
9+
#if defined(CONFIG_HAVE_NMI_WATCHDOG)
10+
#include <asm/nmi.h>
11+
#endif
912

1013
#ifdef CONFIG_LOCKUP_DETECTOR
1114
extern void touch_softlockup_watchdog_sched(void);
@@ -58,28 +61,30 @@ static inline void reset_hung_task_detector(void)
5861
#define NMI_WATCHDOG_ENABLED (1 << NMI_WATCHDOG_ENABLED_BIT)
5962
#define SOFT_WATCHDOG_ENABLED (1 << SOFT_WATCHDOG_ENABLED_BIT)
6063

64+
#if defined(CONFIG_HARDLOCKUP_DETECTOR)
65+
extern void hardlockup_detector_disable(void);
66+
#else
67+
static inline void hardlockup_detector_disable(void) {}
68+
#endif
69+
70+
#if defined(CONFIG_HARDLOCKUP_DETECTOR) || defined(CONFIG_HAVE_NMI_WATCHDOG)
71+
extern void arch_touch_nmi_watchdog(void);
72+
#else
73+
static inline void arch_touch_nmi_watchdog(void) {}
74+
#endif
75+
6176
/**
6277
* touch_nmi_watchdog - restart NMI watchdog timeout.
6378
*
6479
* If the architecture supports the NMI watchdog, touch_nmi_watchdog()
6580
* may be used to reset the timeout - for code which intentionally
6681
* disables interrupts for a long time. This call is stateless.
6782
*/
68-
#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
69-
#include <asm/nmi.h>
70-
extern void touch_nmi_watchdog(void);
71-
#else
7283
static inline void touch_nmi_watchdog(void)
7384
{
85+
arch_touch_nmi_watchdog();
7486
touch_softlockup_watchdog();
7587
}
76-
#endif
77-
78-
#if defined(CONFIG_HARDLOCKUP_DETECTOR)
79-
extern void hardlockup_detector_disable(void);
80-
#else
81-
static inline void hardlockup_detector_disable(void) {}
82-
#endif
8388

8489
/*
8590
* Create trigger_all_cpu_backtrace() out of the arch-provided

kernel/watchdog_hld.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static int __init hardlockup_panic_setup(char *str)
5656
}
5757
__setup("nmi_watchdog=", hardlockup_panic_setup);
5858

59-
void touch_nmi_watchdog(void)
59+
void arch_touch_nmi_watchdog(void)
6060
{
6161
/*
6262
* Using __raw here because some code paths have
@@ -66,9 +66,8 @@ void touch_nmi_watchdog(void)
6666
* going off.
6767
*/
6868
raw_cpu_write(watchdog_nmi_touch, true);
69-
touch_softlockup_watchdog();
7069
}
71-
EXPORT_SYMBOL(touch_nmi_watchdog);
70+
EXPORT_SYMBOL(arch_touch_nmi_watchdog);
7271

7372
static struct perf_event_attr wd_hw_attr = {
7473
.type = PERF_TYPE_HARDWARE,

0 commit comments

Comments
 (0)