mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mikael Pettersson <mikpe@csd.uu.se>
To: marcelo@conectiva.com.br
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH][2.4.21-pre1] check_nmi_watchdog() excessive stack usage
Date: Thu, 12 Dec 2002 15:02:19 +0100 (MET)	[thread overview]
Message-ID: <200212121402.PAA12918@harpo.it.uu.se> (raw)

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;
 		}

                 reply	other threads:[~2002-12-12 13:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200212121402.PAA12918@harpo.it.uu.se \
    --to=mikpe@csd.uu.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®