Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 79797
b: refs/heads/master
c: 416b721
h: refs/heads/master
i:
  79795: d59a56b
v: v3
  • Loading branch information
Hiroshi Shimamoto authored and Ingo Molnar committed Jan 30, 2008
1 parent 5bd1d15 commit f51c846
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 55 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6ea8bad1c06c8ccde381f1c848afe6a245bb33b5
refs/heads/master: 416b72182ac3f3f4931ed17d0256b1d805d1b553
14 changes: 8 additions & 6 deletions trunk/arch/x86/kernel/nmi_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu);

static int endflag __initdata = 0;

#ifdef CONFIG_SMP
/* The performance counters used by NMI_LOCAL_APIC don't trigger when
* the CPU is idle. To make sure the NMI watchdog really ticks on all
* CPUs during the test make them busy.
*/
static __init void nmi_cpu_busy(void *data)
{
#ifdef CONFIG_SMP
local_irq_enable_in_hardirq();
/* Intentionally don't use cpu_relax here. This is
to make sure that the performance counter really ticks,
Expand All @@ -67,8 +67,8 @@ static __init void nmi_cpu_busy(void *data)
care if they get somewhat less cycles. */
while (endflag == 0)
mb();
#endif
}
#endif

static int __init check_nmi_watchdog(void)
{
Expand All @@ -87,11 +87,13 @@ static int __init check_nmi_watchdog(void)

printk(KERN_INFO "Testing NMI watchdog ... ");

#ifdef CONFIG_SMP
if (nmi_watchdog == NMI_LOCAL_APIC)
smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0);
#endif

for_each_possible_cpu(cpu)
prev_nmi_count[cpu] = per_cpu(irq_stat, cpu).__nmi_count;
prev_nmi_count[cpu] = nmi_count(cpu);
local_irq_enable();
mdelay((20*1000)/nmi_hz); // wait 20 ticks

Expand Down Expand Up @@ -237,10 +239,10 @@ void acpi_nmi_disable(void)
on_each_cpu(__acpi_nmi_disable, NULL, 0, 1);
}

void setup_apic_nmi_watchdog (void *unused)
void setup_apic_nmi_watchdog(void *unused)
{
if (__get_cpu_var(wd_enabled))
return;
return;

/* cheap hack to support suspend/resume */
/* if cpu0 is not active neither should the other cpus */
Expand Down Expand Up @@ -329,7 +331,7 @@ __kprobes int nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
unsigned int sum;
int touched = 0;
int cpu = smp_processor_id();
int rc=0;
int rc = 0;

/* check for other users first */
if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT)
Expand Down
95 changes: 47 additions & 48 deletions trunk/arch/x86/kernel/nmi_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,61 +78,60 @@ static __init void nmi_cpu_busy(void *data)
}
#endif

int __init check_nmi_watchdog (void)
int __init check_nmi_watchdog(void)
{
int *counts;
int *prev_nmi_count;
int cpu;

if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DISABLED))
if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DISABLED))
return 0;

if (!atomic_read(&nmi_active))
return 0;

counts = kmalloc(NR_CPUS * sizeof(int), GFP_KERNEL);
if (!counts)
prev_nmi_count = kmalloc(NR_CPUS * sizeof(int), GFP_KERNEL);
if (!prev_nmi_count)
return -1;

printk(KERN_INFO "testing NMI watchdog ... ");
printk(KERN_INFO "Testing NMI watchdog ... ");

#ifdef CONFIG_SMP
if (nmi_watchdog == NMI_LOCAL_APIC)
smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0);
#endif

for (cpu = 0; cpu < NR_CPUS; cpu++)
counts[cpu] = cpu_pda(cpu)->__nmi_count;
prev_nmi_count[cpu] = cpu_pda(cpu)->__nmi_count;
local_irq_enable();
mdelay((20*1000)/nmi_hz); // wait 20 ticks

for_each_online_cpu(cpu) {
if (!per_cpu(wd_enabled, cpu))
continue;
if (cpu_pda(cpu)->__nmi_count - counts[cpu] <= 5) {
if (cpu_pda(cpu)->__nmi_count - prev_nmi_count[cpu] <= 5) {
printk(KERN_WARNING "WARNING: CPU#%d: NMI "
"appears to be stuck (%d->%d)!\n",
cpu,
counts[cpu],
cpu_pda(cpu)->__nmi_count);
cpu,
prev_nmi_count[cpu],
cpu_pda(cpu)->__nmi_count);
per_cpu(wd_enabled, cpu) = 0;
atomic_dec(&nmi_active);
}
}
endflag = 1;
if (!atomic_read(&nmi_active)) {
kfree(counts);
kfree(prev_nmi_count);
atomic_set(&nmi_active, -1);
endflag = 1;
return -1;
}
endflag = 1;
printk("OK.\n");

/* now that we know it works we can reduce NMI frequency to
something more reasonable; makes a difference in some configs */
if (nmi_watchdog == NMI_LOCAL_APIC)
nmi_hz = lapic_adjust_nmi_hz(1);

kfree(counts);
kfree(prev_nmi_count);
return 0;
}

Expand All @@ -159,34 +158,6 @@ static int __init setup_nmi_watchdog(char *str)

__setup("nmi_watchdog=", setup_nmi_watchdog);


static void __acpi_nmi_disable(void *__unused)
{
apic_write(APIC_LVT0, APIC_DM_NMI | APIC_LVT_MASKED);
}

/*
* Disable timer based NMIs on all CPUs:
*/
void acpi_nmi_disable(void)
{
if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC)
on_each_cpu(__acpi_nmi_disable, NULL, 0, 1);
}

static void __acpi_nmi_enable(void *__unused)
{
apic_write(APIC_LVT0, APIC_DM_NMI);
}

/*
* Enable timer based NMIs on all CPUs:
*/
void acpi_nmi_enable(void)
{
if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC)
on_each_cpu(__acpi_nmi_enable, NULL, 0, 1);
}
#ifdef CONFIG_PM

static int nmi_pm_active; /* nmi_active before suspend */
Expand Down Expand Up @@ -217,7 +188,7 @@ static struct sysdev_class nmi_sysclass = {
};

static struct sys_device device_lapic_nmi = {
.id = 0,
.id = 0,
.cls = &nmi_sysclass,
};

Expand All @@ -231,7 +202,7 @@ static int __init init_lapic_nmi_sysfs(void)
if (nmi_watchdog != NMI_LOCAL_APIC)
return 0;

if ( atomic_read(&nmi_active) < 0 )
if (atomic_read(&nmi_active) < 0)
return 0;

error = sysdev_class_register(&nmi_sysclass);
Expand All @@ -244,9 +215,37 @@ late_initcall(init_lapic_nmi_sysfs);

#endif /* CONFIG_PM */

static void __acpi_nmi_enable(void *__unused)
{
apic_write(APIC_LVT0, APIC_DM_NMI);
}

/*
* Enable timer based NMIs on all CPUs:
*/
void acpi_nmi_enable(void)
{
if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC)
on_each_cpu(__acpi_nmi_enable, NULL, 0, 1);
}

static void __acpi_nmi_disable(void *__unused)
{
apic_write(APIC_LVT0, APIC_DM_NMI | APIC_LVT_MASKED);
}

/*
* Disable timer based NMIs on all CPUs:
*/
void acpi_nmi_disable(void)
{
if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC)
on_each_cpu(__acpi_nmi_disable, NULL, 0, 1);
}

void setup_apic_nmi_watchdog(void *unused)
{
if (__get_cpu_var(wd_enabled) == 1)
if (__get_cpu_var(wd_enabled))
return;

/* cheap hack to support suspend/resume */
Expand Down Expand Up @@ -311,8 +310,9 @@ void touch_nmi_watchdog(void)
}
}

touch_softlockup_watchdog();
touch_softlockup_watchdog();
}
EXPORT_SYMBOL(touch_nmi_watchdog);

int __kprobes nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
{
Expand Down Expand Up @@ -479,4 +479,3 @@ void __trigger_all_cpu_backtrace(void)

EXPORT_SYMBOL(nmi_active);
EXPORT_SYMBOL(nmi_watchdog);
EXPORT_SYMBOL(touch_nmi_watchdog);

0 comments on commit f51c846

Please sign in to comment.