PATCH: Allow users to force a panic on NMI
The default Linux behaviour on an NMI of either memory or unknown is to continue operation. For many environments such as scientific computing it is preferable that the box is taken out and the error dealt with than an uncorrected parity/ECC error get propogated.
A small number of systems do generate NMI's for bizarre random reasons such as power management so the default is unchanged. In other respects the new proc/sys entry works like the existing panic controls already in that directory.
This is separate to the edac support - EDAC allows supported chipsets to handle ECC errors well, this change allows unsupported cases to at least panic rather than cause problems further down the line.
include/linux/sysctl.h +1 -0
@@ -146,6 +146,7 @@KERN_RANDOMIZE =68 ,/* int: randomize virtual address space */ KERN_SETUID_DUMPABLE =69 ,/* int: behaviour of dumps for setuid core */ KERN_SPIN_RETRY =70 ,/* int: number of spinlock retries */ + KERN_PANIC_ON_NMI=71, /* int: whether we will panic on an unrecovered NMI */ };
kernel/panic.c +1 -0
@@ -22,6 +22,7 @@int panic_timeout;int panic_on_oops; +int panic_on_unrecovered_nmi;int tainted;EXPORT_SYMBOL (panic_timeout);
kernel/sysctl.c +8 -0
@@ -594,6 +594,14 @@ .proc_handler = &proc_dointvec, }, { + .ctl_name = KERN_PANIC_ON_NMI, + .procname = "panic_on_unrecovered_nmi", + .data = &panic_on_unrecovered_nmi, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { .ctl_name = KERN_PRINTK_RATELIMIT, .procname = "printk_ratelimit", .data = &printk_ratelimit_jiffies,
arch/i386/kernel/traps.c +6 -0
@@ -576,6 +576,9 @@ {printk ("Uhhuh. NMI received. Dazed and confused, but trying to continue\n" );printk ("You probably have a hardware problem with your RAM chips\n" ); + +if (panic_on_unrecovered_nmi) +panic ("NMI: Not continuing" );/* Clear and disable the memory parity error line. */ clear_mem_error (reason);
@@ -611,6 +614,9 @@ reason, smp_processor_id());printk ("Dazed and confused, but trying to continue\n" );printk ("Do you have a strange power saving mode enabled?\n" ); + +if (panic_on_unrecovered_nmi) +panic ("NMI: Not continuing" ); }static DEFINE_SPINLOCK (nmi_print_lock);
arch/x86_64/kernel/traps.c +6 -0
@@ -563,6 +563,9 @@printk ("Uhhuh. NMI received. Dazed and confused, but trying to continue\n" );printk ("You probably have a hardware problem with your RAM chips\n" ); +if (panic_on_unrecovered_nmi) +panic ("NMI: Not continuing" ); +/* Clear and disable the memory parity error line. */ reason = (reason &0xf ) |4 ;outb (reason,0x61 );
@@ -585,6 +588,9 @@ {printk ("Uhhuh. NMI received for unknown reason %02x.\n" , reason);printk ("Dazed and confused, but trying to continue\n" );printk ("Do you have a strange power saving mode enabled?\n" ); + +if (panic_on_unrecovered_nmi) +panic ("NMI: Not continuing" ); }/* Runs on IST stack. This code must keep interrupts off all the time.
Quoted 5 lines · Alan Cox
The default Linux behaviour on an NMI of either memory or unknown is to continue operation. For many environments such as scientific computing it is preferable that the box is taken out and the error dealt with than an uncorrected parity/ECC error get propogated.
[snip]
arch/i386/kernel/traps.c line 581
Quoted 7 lines
{ printk("Uhhuh. NMI received. Dazed and confused, but trying to continue\n"); printk("You probably have a hardware problem with your RAM chips\n");arch/i386/kernel/traps.c +3
-0+ +if (panic_on_unrecovered_nmi) +panic ("NMI: Not continuing" );
How about something like this instead?
printk(KERN_WARNING "Uhhuh. NMI received. Dazed and confused\n"); printk(KERN_WARNING "You probably have a hardware problem with your RAM chips\n");
if (panic_on_unrecovered_nmi)
panic("NMI: panic_on_unrecovered_nmi enabled - Not continuing");else
printk(KERN_WARNING "NMI: panic_on_unrecovered_nmi disabled -
continuing\n");
First of all then it won't start out by saying that it's going to continue, only to panic a few lines down.
Secondly it shows clearly to anyone reading the messages that there's a control available for changing the behaviour, and that person can then go look up how that's done.
Just a suggestion...
--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
Re: PATCH: Allow users to force a panic on NMI - Header file
In reply to Alan CoxForgot the header file in that one.
include/linux/kernel.h +1 -0
@@ -170,6 +170,7 @@extern int oops_in_progress;/* If set, an oops, panic(), BUG() or die() is in progress */ extern __deprecated_for_modules int panic_timeout;extern int panic_on_oops; +extern int panic_on_unrecovered_nmi;extern int tainted;extern const char *print_tainted (void );extern void add_taint (unsigned );