ChangeSet 1.1413, 2005/05/16 10:49:48+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx
Fix the watchdog disable/enable interface. This cleans up common code
somewhat.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
arch/ia64/xenmisc.c | 2 --
arch/x86/cdb.c | 6 ++----
arch/x86/domain.c | 2 +-
arch/x86/nmi.c | 23 ++++++++++++++++++++++-
arch/x86/setup.c | 3 ++-
arch/x86/traps.c | 2 +-
arch/x86/x86_32/traps.c | 3 +--
arch/x86/x86_64/traps.c | 3 +--
common/page_alloc.c | 7 +++----
drivers/char/console.c | 8 +++-----
include/asm-ia64/config.h | 4 ++--
include/asm-x86/apic.h | 5 +++--
12 files changed, 41 insertions(+), 27 deletions(-)
diff -Nru a/xen/arch/ia64/xenmisc.c b/xen/arch/ia64/xenmisc.c
--- a/xen/arch/ia64/xenmisc.c 2005-05-16 07:05:13 -04:00
+++ b/xen/arch/ia64/xenmisc.c 2005-05-16 07:05:13 -04:00
@@ -23,8 +23,6 @@
int phys_proc_id[NR_CPUS];
unsigned long loops_per_jiffy = (1<<12); // from linux/init/main.c
-unsigned int watchdog_on = 0; // from arch/x86/nmi.c ?!?
-
void unw_init(void) { printf("unw_init() skipped (NEED FOR KERNEL UNWIND)\n");
}
void ia64_mca_init(void) { printf("ia64_mca_init() skipped (Machine check
abort handling)\n"); }
void ia64_mca_cpu_init(void *x) { }
diff -Nru a/xen/arch/x86/cdb.c b/xen/arch/x86/cdb.c
--- a/xen/arch/x86/cdb.c 2005-05-16 07:05:13 -04:00
+++ b/xen/arch/x86/cdb.c 2005-05-16 07:05:13 -04:00
@@ -327,7 +327,6 @@
static atomic_t xendbg_running = ATOMIC_INIT(1);
static char recv_buf[4096];
unsigned flags;
- unsigned old_watchdog;
if (xdb_ctx.serhnd < 0) {
dbg_printk("Debugger not ready yet.\n");
@@ -358,8 +357,7 @@
interrupts while we're here. */
local_irq_save(flags);
- old_watchdog = watchdog_on;
- watchdog_on = 0;
+ watchdog_disable();
/* Shouldn't really do this, but otherwise we stop for no
obvious reason, which is Bad */
@@ -385,7 +383,7 @@
ASSERT(!local_irq_is_enabled());
}
}
- watchdog_on = old_watchdog;
+ watchdog_enable();
atomic_inc(&xendbg_running);
local_irq_restore(flags);
return 0;
diff -Nru a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c 2005-05-16 07:05:13 -04:00
+++ b/xen/arch/x86/domain.c 2005-05-16 07:05:13 -04:00
@@ -186,7 +186,7 @@
void machine_halt(void)
{
- watchdog_on = 0;
+ watchdog_disable();
smp_call_function(__machine_halt, NULL, 1, 0);
__machine_halt(NULL);
}
diff -Nru a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c
--- a/xen/arch/x86/nmi.c 2005-05-16 07:05:13 -04:00
+++ b/xen/arch/x86/nmi.c 2005-05-16 07:05:13 -04:00
@@ -28,7 +28,6 @@
#include <asm/debugger.h>
unsigned int nmi_watchdog = NMI_NONE;
-unsigned int watchdog_on = 0;
static unsigned int nmi_hz = HZ;
unsigned int nmi_perfctr_msr; /* the MSR to reset in NMI handler */
@@ -255,6 +254,28 @@
static unsigned int
last_irq_sums [NR_CPUS],
alert_counter [NR_CPUS];
+
+static spinlock_t watchdog_lock = SPIN_LOCK_UNLOCKED;
+static unsigned int watchdog_disable_count = 1;
+static unsigned int watchdog_on;
+
+void watchdog_disable(void)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&watchdog_lock, flags);
+ if ( watchdog_disable_count++ == 0 )
+ watchdog_on = 0;
+ spin_unlock_irqrestore(&watchdog_lock, flags);
+}
+
+void watchdog_enable(void)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&watchdog_lock, flags);
+ if ( --watchdog_disable_count == 0 )
+ watchdog_on = 1;
+ spin_unlock_irqrestore(&watchdog_lock, flags);
+}
void touch_nmi_watchdog (void)
{
diff -Nru a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c 2005-05-16 07:05:13 -04:00
+++ b/xen/arch/x86/setup.c 2005-05-16 07:05:13 -04:00
@@ -450,7 +450,8 @@
while ( wait_init_idle != 0 )
cpu_relax();
- watchdog_on = 1;
+ watchdog_enable();
+
#ifdef __x86_64__ /* x86_32 uses low mappings when building DOM0. */
zap_low_mappings();
#endif
diff -Nru a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
--- a/xen/arch/x86/traps.c 2005-05-16 07:05:13 -04:00
+++ b/xen/arch/x86/traps.c 2005-05-16 07:05:13 -04:00
@@ -199,7 +199,7 @@
"machine check", "simd error"
};
- watchdog_on = 0;
+ watchdog_disable();
show_registers(regs);
diff -Nru a/xen/arch/x86/x86_32/traps.c b/xen/arch/x86/x86_32/traps.c
--- a/xen/arch/x86/x86_32/traps.c 2005-05-16 07:05:13 -04:00
+++ b/xen/arch/x86/x86_32/traps.c 2005-05-16 07:05:13 -04:00
@@ -111,8 +111,7 @@
struct tss_struct *tss = &doublefault_tss;
unsigned int cpu = ((tss->back_link>>3)-__FIRST_TSS_ENTRY)>>1;
- /* Disable the NMI watchdog. It's useless now. */
- watchdog_on = 0;
+ watchdog_disable();
console_force_unlock();
diff -Nru a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c
--- a/xen/arch/x86/x86_64/traps.c 2005-05-16 07:05:13 -04:00
+++ b/xen/arch/x86/x86_64/traps.c 2005-05-16 07:05:13 -04:00
@@ -60,8 +60,7 @@
asmlinkage void double_fault(void);
asmlinkage void do_double_fault(struct cpu_user_regs *regs)
{
- /* Disable the NMI watchdog. It's useless now. */
- watchdog_on = 0;
+ watchdog_disable();
console_force_unlock();
diff -Nru a/xen/common/page_alloc.c b/xen/common/page_alloc.c
--- a/xen/common/page_alloc.c 2005-05-16 07:05:13 -04:00
+++ b/xen/common/page_alloc.c 2005-05-16 07:05:13 -04:00
@@ -356,15 +356,13 @@
unsigned long pfn, flags;
printk("Scrubbing Free RAM: ");
+ watchdog_disable();
for ( pfn = 0; pfn < (bitmap_size * 8); pfn++ )
{
- /* Every 100MB, print a progress dot and appease the watchdog. */
+ /* Every 100MB, print a progress dot. */
if ( (pfn % ((100*1024*1024)/PAGE_SIZE)) == 0 )
- {
printk(".");
- touch_nmi_watchdog();
- }
/* Quick lock-free check. */
if ( allocated_in_map(pfn) )
@@ -383,6 +381,7 @@
spin_unlock_irqrestore(&heap_lock, flags);
}
+ watchdog_enable();
printk("done.\n");
}
diff -Nru a/xen/drivers/char/console.c b/xen/drivers/char/console.c
--- a/xen/drivers/char/console.c 2005-05-16 07:05:13 -04:00
+++ b/xen/drivers/char/console.c 2005-05-16 07:05:13 -04:00
@@ -502,14 +502,12 @@
void debugtrace_dump(void)
{
- int _watchdog_on = watchdog_on;
unsigned long flags;
if ( (debugtrace_bytes == 0) || !debugtrace_used )
return;
- /* Watchdog can trigger if we print a really large buffer. */
- watchdog_on = 0;
+ watchdog_disable();
spin_lock_irqsave(&debugtrace_lock, flags);
@@ -529,7 +527,7 @@
spin_unlock_irqrestore(&debugtrace_lock, flags);
- watchdog_on = _watchdog_on;
+ watchdog_enable();
}
void debugtrace_printk(const char *fmt, ...)
@@ -635,7 +633,7 @@
__putstr("Reboot in five seconds...\n");
spin_unlock_irqrestore(&console_lock, flags);
- watchdog_on = 0;
+ watchdog_disable();
mdelay(5000);
machine_restart(0);
}
diff -Nru a/xen/include/asm-ia64/config.h b/xen/include/asm-ia64/config.h
--- a/xen/include/asm-ia64/config.h 2005-05-16 07:05:13 -04:00
+++ b/xen/include/asm-ia64/config.h 2005-05-16 07:05:13 -04:00
@@ -29,7 +29,8 @@
#define FASTCALL(x) x // see linux/include/linux/linkage.h
#define fastcall // " "
-#define touch_nmi_watchdog()
+#define watchdog_disable() ((void)0)
+#define watchdog_enable() ((void)0)
// from linux/include/linux/types.h
#define CLEAR_BITMAP(name,bits) \
memset(name, 0, BITS_TO_LONGS(bits)*sizeof(unsigned long))
@@ -261,7 +262,6 @@
// these declarations got moved at some point, find a better place for them
extern int opt_noht;
extern int ht_per_core;
-extern unsigned int watchdog_on;
// xen/include/asm/config.h
/******************************************************************************
diff -Nru a/xen/include/asm-x86/apic.h b/xen/include/asm-x86/apic.h
--- a/xen/include/asm-x86/apic.h 2005-05-16 07:05:13 -04:00
+++ b/xen/include/asm-x86/apic.h 2005-05-16 07:05:13 -04:00
@@ -104,14 +104,15 @@
extern void disable_timer_nmi_watchdog(void);
extern void enable_timer_nmi_watchdog(void);
extern void nmi_watchdog_tick (struct cpu_user_regs *regs);
-extern void touch_nmi_watchdog(void);
extern int APIC_init_uniprocessor (void);
extern void disable_APIC_timer(void);
extern void enable_APIC_timer(void);
-extern unsigned int watchdog_on;
extern int check_nmi_watchdog (void);
extern void enable_NMI_through_LVT0 (void * dummy);
+
+extern void watchdog_disable(void);
+extern void watchdog_enable(void);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|