From d4faf5a948c03ffe61b4bfd1ebcdc93343727ca4 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Thu, 8 Mar 2012 09:23:27 +0000 Subject: [PATCH] NMI: Command line parameter for watchdog timeout Introduce a command parameter to set the watchtog timeout. Manually specifying "watchdog_timeout=" on the command line will also turn the watchdog on. For consistency, move opt_watchdog into nmi.c along with opt_watchdog_timeout. Signed-off-by: Andrew Cooper Committed-by: Keir Fraser --- docs/misc/xen-command-line.markdown | 12 +++++++++++- xen/arch/x86/nmi.c | 17 +++++++++++++++-- xen/arch/x86/setup.c | 5 +---- xen/include/asm-x86/nmi.h | 3 +++ 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown index 986264cdf4..61f5328bdf 100644 --- a/docs/misc/xen-command-line.markdown +++ b/docs/misc/xen-command-line.markdown @@ -391,7 +391,17 @@ The optional `keep` parameter causes Xen to continue using the vga console even ### watchdog > `= ` -Run an NMI watchdog on each processor. Defaults to disabled. +> Default: `false` + +Run an NMI watchdog on each processor. If a processor is stuck for longer than the watchdog\_timeout, a panic occurs. + +### watchdog\_timeout +> `= ` + +> Default: `5` + +Set the NMI watchdog timeout in seconds. Specifying `0` will turn off the watchdog. + ### x2apic ### x2apic\_phys ### xencons diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c index 2fd864e868..4e2cd53b75 100644 --- a/xen/arch/x86/nmi.c +++ b/xen/arch/x86/nmi.c @@ -40,6 +40,19 @@ static unsigned int nmi_p4_cccr_val; static DEFINE_PER_CPU(struct timer, nmi_timer); static DEFINE_PER_CPU(unsigned int, nmi_timer_ticks); +/* opt_watchdog: If true, run a watchdog NMI on each processor. */ +bool_t __initdata opt_watchdog = 0; +boolean_param("watchdog", opt_watchdog); + +/* opt_watchdog_timeout: Number of seconds to wait before panic. */ +static unsigned int opt_watchdog_timeout = 5; +static void parse_watchdog_timeout(char * s) +{ + opt_watchdog_timeout = simple_strtoull(s, NULL, 0); + opt_watchdog = !!opt_watchdog_timeout; +} +custom_param("watchdog_timeout", parse_watchdog_timeout); + /* * lapic_nmi_owner tracks the ownership of the lapic NMI hardware: * - it may be reserved by some other driver, or not @@ -425,11 +438,11 @@ void nmi_watchdog_tick(struct cpu_user_regs * regs) !atomic_read(&watchdog_disable_count) ) { /* - * Ayiee, looks like this CPU is stuck ... wait a few IRQs (5 seconds) + * Ayiee, looks like this CPU is stuck ... wait for the timeout * before doing the oops ... */ this_cpu(alert_counter)++; - if ( this_cpu(alert_counter) == 5*nmi_hz ) + if ( this_cpu(alert_counter) == opt_watchdog_timeout*nmi_hz ) { console_force_unlock(); printk("Watchdog timer detects that CPU%d is stuck!\n", diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ae236c94c3..b9da9851c9 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -45,6 +45,7 @@ #include /* for generic_apic_probe */ #include #include +#include /* opt_nosmp: If true, secondary processors are ignored. */ static bool_t __initdata opt_nosmp; @@ -54,10 +55,6 @@ boolean_param("nosmp", opt_nosmp); static unsigned int __initdata max_cpus; integer_param("maxcpus", max_cpus); -/* opt_watchdog: If true, run a watchdog NMI on each processor. */ -static bool_t __initdata opt_watchdog; -boolean_param("watchdog", opt_watchdog); - /* smep: Enable/disable Supervisor Mode Execution Protection (default on). */ static bool_t __initdata disable_smep; invbool_param("smep", disable_smep); diff --git a/xen/include/asm-x86/nmi.h b/xen/include/asm-x86/nmi.h index af1ff2e008..98b5e04341 100644 --- a/xen/include/asm-x86/nmi.h +++ b/xen/include/asm-x86/nmi.h @@ -5,6 +5,9 @@ #include struct cpu_user_regs; + +/* Watchdog boolean from the command line */ +extern bool_t opt_watchdog; typedef int (*nmi_callback_t)(struct cpu_user_regs *regs, int cpu); -- 2.30.2