Skip to content

Commit 5dc3055

Browse files
dzickusrhIngo Molnar
authored andcommitted
x86, NMI: Add back unknown_nmi_panic and nmi_watchdog sysctls
Originally adapted from Huang Ying's patch which moved the unknown_nmi_panic to the traps.c file. Because the old nmi watchdog was deleted before this change happened, the unknown_nmi_panic sysctl was lost. This re-adds it. Also, the nmi_watchdog sysctl was re-implemented and its documentation updated accordingly. Patch-inspired-by: Huang Ying <ying.huang@intel.com> Signed-off-by: Don Zickus <dzickus@redhat.com> Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com> Acked-by: Yinghai Lu <yinghai@kernel.org> Cc: fweisbec@gmail.com LKML-Reference: <1291068437-5331-3-git-send-email-dzickus@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 96a84c2 commit 5dc3055

6 files changed

Lines changed: 30 additions & 18 deletions

File tree

‎Documentation/kernel-parameters.txt‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,20 +1579,12 @@ and is between 256 and 4096 characters. It is defined in the file
15791579

15801580
nmi_watchdog= [KNL,BUGS=X86] Debugging features for SMP kernels
15811581
Format: [panic,][num]
1582-
Valid num: 0,1,2
1582+
Valid num: 0
15831583
0 - turn nmi_watchdog off
1584-
1 - use the IO-APIC timer for the NMI watchdog
1585-
2 - use the local APIC for the NMI watchdog using
1586-
a performance counter. Note: This will use one
1587-
performance counter and the local APIC's performance
1588-
vector.
15891584
When panic is specified, panic when an NMI watchdog
15901585
timeout occurs.
15911586
This is useful when you use a panic=... timeout and
15921587
need the box quickly up again.
1593-
Instead of 1 and 2 it is possible to use the following
1594-
symbolic names: lapic and ioapic
1595-
Example: nmi_watchdog=2 or nmi_watchdog=panic,lapic
15961588

15971589
netpoll.carrier_timeout=
15981590
[NET] Specifies amount of time (in seconds) that

‎arch/x86/kernel/apic/hw_nmi.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,3 @@ static int __init register_trigger_all_cpu_backtrace(void)
9999
}
100100
early_initcall(register_trigger_all_cpu_backtrace);
101101
#endif
102-
103-
/* STUB calls to mimic old nmi_watchdog behaviour */
104-
int unknown_nmi_panic;

‎arch/x86/kernel/traps.c‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ EXPORT_SYMBOL_GPL(used_vectors);
8383

8484
static int ignore_nmis;
8585

86+
int unknown_nmi_panic;
87+
8688
static inline void conditional_sti(struct pt_regs *regs)
8789
{
8890
if (regs->flags & X86_EFLAGS_IF)
@@ -300,6 +302,13 @@ do_general_protection(struct pt_regs *regs, long error_code)
300302
die("general protection fault", regs, error_code);
301303
}
302304

305+
static int __init setup_unknown_nmi_panic(char *str)
306+
{
307+
unknown_nmi_panic = 1;
308+
return 1;
309+
}
310+
__setup("unknown_nmi_panic", setup_unknown_nmi_panic);
311+
303312
static notrace __kprobes void
304313
mem_parity_error(unsigned char reason, struct pt_regs *regs)
305314
{
@@ -371,7 +380,7 @@ unknown_nmi_error(unsigned char reason, struct pt_regs *regs)
371380
reason, smp_processor_id());
372381

373382
printk(KERN_EMERG "Do you have a strange power saving mode enabled?\n");
374-
if (panic_on_unrecovered_nmi)
383+
if (unknown_nmi_panic || panic_on_unrecovered_nmi)
375384
panic("NMI: Not continuing");
376385

377386
printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
@@ -397,11 +406,8 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs)
397406
if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT)
398407
== NOTIFY_STOP)
399408
return;
400-
401-
unknown_nmi_error(reason, regs);
402-
#else
403-
unknown_nmi_error(reason, regs);
404409
#endif
410+
unknown_nmi_error(reason, regs);
405411

406412
return;
407413
}

‎kernel/sysctl.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,22 @@ static struct ctl_table kern_table[] = {
745745
.extra1 = &zero,
746746
.extra2 = &one,
747747
},
748+
{
749+
.procname = "nmi_watchdog",
750+
.data = &watchdog_enabled,
751+
.maxlen = sizeof (int),
752+
.mode = 0644,
753+
.proc_handler = proc_dowatchdog_enabled,
754+
},
755+
#endif
756+
#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
757+
{
758+
.procname = "unknown_nmi_panic",
759+
.data = &unknown_nmi_panic,
760+
.maxlen = sizeof (int),
761+
.mode = 0644,
762+
.proc_handler = proc_dointvec,
763+
},
748764
#endif
749765
#if defined(CONFIG_X86)
750766
{

‎kernel/sysctl_binary.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ static const struct bin_table bin_kern_table[] = {
136136
{ CTL_INT, KERN_IA64_UNALIGNED, "ignore-unaligned-usertrap" },
137137
{ CTL_INT, KERN_COMPAT_LOG, "compat-log" },
138138
{ CTL_INT, KERN_MAX_LOCK_DEPTH, "max_lock_depth" },
139-
{ CTL_INT, KERN_NMI_WATCHDOG, "nmi_watchdog" },
140139
{ CTL_INT, KERN_PANIC_ON_NMI, "panic_on_unrecovered_nmi" },
141140
{}
142141
};

‎kernel/watchdog.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ static int __init hardlockup_panic_setup(char *str)
5757
{
5858
if (!strncmp(str, "panic", 5))
5959
hardlockup_panic = 1;
60+
else if (!strncmp(str, "0", 1))
61+
no_watchdog = 1;
6062
return 1;
6163
}
6264
__setup("nmi_watchdog=", hardlockup_panic_setup);

0 commit comments

Comments
 (0)