Impact: reduce memory usage, use alloc_percpu(). Instead of allocating an nr_cpu_ids array, most places should be using percpu_alloc(). This doesn't waste space if cpu numbers aren't contiguous. Signed-off-by: Rusty Russell Signed-off-by: Mike Travis --- arch/x86/kernel/nmi.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) --- linux-2.6-for-ingo.orig/arch/x86/kernel/nmi.c +++ linux-2.6-for-ingo/arch/x86/kernel/nmi.c @@ -114,13 +114,13 @@ static __init void nmi_cpu_busy(void *da } #endif -static void report_broken_nmi(int cpu, int *prev_nmi_count) +static void report_broken_nmi(int cpu, int prev_nmi_count) { printk(KERN_CONT "\n"); printk(KERN_WARNING "WARNING: CPU#%d: NMI appears to be stuck (%d->%d)!\n", - cpu, prev_nmi_count[cpu], get_nmi_count(cpu)); + cpu, prev_nmi_count, get_nmi_count(cpu)); printk(KERN_WARNING "Please report this to bugzilla.kernel.org,\n"); @@ -139,7 +139,7 @@ int __init check_nmi_watchdog(void) if (!nmi_watchdog_active() || !atomic_read(&nmi_active)) return 0; - prev_nmi_count = kmalloc(nr_cpu_ids * sizeof(int), GFP_KERNEL); + prev_nmi_count = alloc_percpu(unsigned int); if (!prev_nmi_count) goto error; @@ -151,19 +151,19 @@ int __init check_nmi_watchdog(void) #endif for_each_possible_cpu(cpu) - prev_nmi_count[cpu] = get_nmi_count(cpu); + *per_cpu_ptr(prev_nmi_count, cpu) = get_nmi_count(cpu); local_irq_enable(); mdelay((20 * 1000) / nmi_hz); /* wait 20 ticks */ for_each_online_cpu(cpu) { if (!per_cpu(wd_enabled, cpu)) continue; - if (get_nmi_count(cpu) - prev_nmi_count[cpu] <= 5) - report_broken_nmi(cpu, prev_nmi_count); + if (get_nmi_count(cpu) - *per_cpu_ptr(prev_nmi_count, cpu) <= 5) + report_broken_nmi(cpu, *per_cpu_ptr(prev_nmi_count,cpu)); } endflag = 1; if (!atomic_read(&nmi_active)) { - kfree(prev_nmi_count); + free_percpu(prev_nmi_count); atomic_set(&nmi_active, -1); goto error; } @@ -176,7 +176,7 @@ int __init check_nmi_watchdog(void) if (nmi_watchdog == NMI_LOCAL_APIC) nmi_hz = lapic_adjust_nmi_hz(1); - kfree(prev_nmi_count); + free_percpu(prev_nmi_count); return 0; error: if (nmi_watchdog == NMI_IO_APIC && !timer_through_8259) -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/