Bläddra i källkod

kernel/watchdog.c: add sysctl knob hardlockup_panic

The only way to enable a hardlockup to panic the machine is to set
'nmi_watchdog=panic' on the kernel command line.

This makes it awkward for end users and folks who want to run automate
tests (like myself).

Mimic the softlockup_panic knob and create a /proc/sys/kernel/hardlockup_panic
knob.

Signed-off-by: Don Zickus <dzickus@redhat.com>
Cc: Ulrich Obergfell <uobergfe@redhat.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Reviewed-by: Aaron Tomlin <atomlin@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Don Zickus 9 år sedan
förälder
incheckning
ac1f591249
4 ändrade filer med 16 tillägg och 3 borttagningar
  1. 3 2
      Documentation/lockup-watchdogs.txt
  2. 1 0
      include/linux/sched.h
  3. 11 0
      kernel/sysctl.c
  4. 1 1
      kernel/watchdog.c

+ 3 - 2
Documentation/lockup-watchdogs.txt

@@ -20,8 +20,9 @@ kernel mode for more than 10 seconds (see "Implementation" below for
 details), without letting other interrupts have a chance to run.
 details), without letting other interrupts have a chance to run.
 Similarly to the softlockup case, the current stack trace is displayed
 Similarly to the softlockup case, the current stack trace is displayed
 upon detection and the system will stay locked up unless the default
 upon detection and the system will stay locked up unless the default
-behavior is changed, which can be done through a compile time knob,
-"BOOTPARAM_HARDLOCKUP_PANIC", and a kernel parameter, "nmi_watchdog"
+behavior is changed, which can be done through a sysctl,
+'hardlockup_panic', a compile time knob, "BOOTPARAM_HARDLOCKUP_PANIC",
+and a kernel parameter, "nmi_watchdog"
 (see "Documentation/kernel-parameters.txt" for details).
 (see "Documentation/kernel-parameters.txt" for details).
 
 
 The panic option can be used in combination with panic_timeout (this
 The panic option can be used in combination with panic_timeout (this

+ 1 - 0
include/linux/sched.h

@@ -384,6 +384,7 @@ extern int proc_dowatchdog_thresh(struct ctl_table *table, int write,
 				  void __user *buffer,
 				  void __user *buffer,
 				  size_t *lenp, loff_t *ppos);
 				  size_t *lenp, loff_t *ppos);
 extern unsigned int  softlockup_panic;
 extern unsigned int  softlockup_panic;
+extern unsigned int  hardlockup_panic;
 void lockup_detector_init(void);
 void lockup_detector_init(void);
 #else
 #else
 static inline void touch_softlockup_watchdog(void)
 static inline void touch_softlockup_watchdog(void)

+ 11 - 0
kernel/sysctl.c

@@ -888,6 +888,17 @@ static struct ctl_table kern_table[] = {
 		.extra1		= &zero,
 		.extra1		= &zero,
 		.extra2		= &one,
 		.extra2		= &one,
 	},
 	},
+#ifdef CONFIG_HARDLOCKUP_DETECTOR
+	{
+		.procname	= "hardlockup_panic",
+		.data		= &hardlockup_panic,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= &zero,
+		.extra2		= &one,
+	},
+#endif
 #ifdef CONFIG_SMP
 #ifdef CONFIG_SMP
 	{
 	{
 		.procname	= "softlockup_all_cpu_backtrace",
 		.procname	= "softlockup_all_cpu_backtrace",

+ 1 - 1
kernel/watchdog.c

@@ -112,7 +112,7 @@ static unsigned long soft_lockup_nmi_warn;
  * Should we panic when a soft-lockup or hard-lockup occurs:
  * Should we panic when a soft-lockup or hard-lockup occurs:
  */
  */
 #ifdef CONFIG_HARDLOCKUP_DETECTOR
 #ifdef CONFIG_HARDLOCKUP_DETECTOR
-static int hardlockup_panic =
+unsigned int __read_mostly hardlockup_panic =
 			CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE;
 			CONFIG_BOOTPARAM_HARDLOCKUP_PANIC_VALUE;
 static unsigned long hardlockup_allcpu_dumped;
 static unsigned long hardlockup_allcpu_dumped;
 /*
 /*