All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][2.4.21-pre1] check_nmi_watchdog() excessive stack usage
@ 2002-12-12 14:02 Mikael Pettersson
  0 siblings, 0 replies; only message in thread
From: Mikael Pettersson @ 2002-12-12 14:02 UTC (permalink / raw)
  To: marcelo; +Cc: linux-kernel

Marcelo,

This patch fixes a problem with excessive stack usage in
arch/i386/kernel/nmi.c:check_nmi_watchdog(). It's a backport
of a fix that has been in the 2.5 kernel for quite a while.
There are no behavioural changes.

The problem is that the code copies NR_CPUS irq_cpustat_t values
to the stack, even though only NR_CPUS ints actually are needed.
irq_cpustat_t values are 24 bytes large, but they are also
____cacheline_aligned, which makes them blow up to 128 bytes
on P4s. That's 128*32 == 4 kilobytes of stack on a P4 SMP kernel,
when 4*32 == 128 bytes suffices.

/Mikael

diff -ruN linux-2.4.21-pre1/arch/i386/kernel/nmi.c linux-2.4.21-pre1.check_nmi/arch/i386/kernel/nmi.c
--- linux-2.4.21-pre1/arch/i386/kernel/nmi.c	2002-08-07 00:52:18.000000000 +0200
+++ linux-2.4.21-pre1.check_nmi/arch/i386/kernel/nmi.c	2002-12-12 14:19:10.000000000 +0100
@@ -72,18 +72,21 @@
 
 int __init check_nmi_watchdog (void)
 {
-	irq_cpustat_t tmp[NR_CPUS];
+	unsigned int prev_nmi_count[NR_CPUS];
 	int j, cpu;
 
 	printk(KERN_INFO "testing NMI watchdog ... ");
 
-	memcpy(tmp, irq_stat, sizeof(tmp));
+	for (j = 0; j < smp_num_cpus; j++) {
+		cpu = cpu_logical_map(j);
+		prev_nmi_count[cpu] = irq_stat[cpu].__nmi_count;
+	}
 	sti();
 	mdelay((10*1000)/nmi_hz); // wait 10 ticks
 
 	for (j = 0; j < smp_num_cpus; j++) {
 		cpu = cpu_logical_map(j);
-		if (nmi_count(cpu) - tmp[cpu].__nmi_count <= 5) {
+		if (nmi_count(cpu) - prev_nmi_count[cpu] <= 5) {
 			printk("CPU#%d: NMI appears to be stuck!\n", cpu);
 			return -1;
 		}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-12-12 13:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-12 14:02 [PATCH][2.4.21-pre1] check_nmi_watchdog() excessive stack usage Mikael Pettersson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.