From: Russ Anderson <rja@sgi.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Russ Anderson <rja@sgi.com>
Subject: [PATCH] x86: Avoid intermixing cpu dump_stack output on multi-processor systems
Date: Thu, 24 May 2012 09:42:29 -0500 [thread overview]
Message-ID: <20120524144229.GA27713@sgi.com> (raw)
When multiple cpus on a multi-processor system call dump_stack()
at the same time, the backtrace lines get intermixed, making
the output worthless. Add a lock so each cpu stack dump comes
out as a coherent set.
For example, when a multi-processor system is NMIed, all of the
cpus call dump_stack() at the same time, resulting in output for
all of cpus getting intermixed, making it impossible to tell what
any individual cpu was doing. With this patch each cpu prints
its stack lines as a coherent set, so one can see what each cpu
was doing.
It has been tested on a 4069 cpu system.
Signed-off-by: Russ Anderson <rja@sgi.com>
---
arch/x86/kernel/dumpstack.c | 3 +++
1 file changed, 3 insertions(+)
Index: linux/arch/x86/kernel/dumpstack.c
===================================================================
--- linux.orig/arch/x86/kernel/dumpstack.c 2012-05-03 14:31:13.602345805 -0500
+++ linux/arch/x86/kernel/dumpstack.c 2012-05-03 14:51:43.805197563 -0500
@@ -186,7 +186,9 @@ void dump_stack(void)
{
unsigned long bp;
unsigned long stack;
+ static DEFINE_SPINLOCK(lock); /* Serialise the printks */
+ spin_lock(&lock);
bp = stack_frame(current, NULL);
printk("Pid: %d, comm: %.20s %s %s %.*s\n",
current->pid, current->comm, print_tainted(),
@@ -194,6 +196,7 @@ void dump_stack(void)
(int)strcspn(init_utsname()->version, " "),
init_utsname()->version);
show_trace(NULL, NULL, &stack, bp);
+ spin_unlock(&lock);
}
EXPORT_SYMBOL(dump_stack);
--
Russ Anderson, OS RAS/Partitioning Project Lead
SGI - Silicon Graphics Inc rja@sgi.com
next reply other threads:[~2012-05-24 14:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-24 14:42 Russ Anderson [this message]
2012-05-24 15:34 ` [PATCH] x86: Avoid intermixing cpu dump_stack output on multi-processor systems Frederic Weisbecker
2012-05-29 18:50 ` Russ Anderson
2012-05-29 17:53 ` Don Zickus
2012-05-29 19:19 ` Russ Anderson
2012-05-29 22:39 ` Don Zickus
2012-05-29 23:11 ` Russ Anderson
2012-05-29 23:54 ` Don Zickus
2012-06-01 22:56 ` Russ Anderson
2012-06-04 14:23 ` Don Zickus
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=20120524144229.GA27713@sgi.com \
--to=rja@sgi.com \
--cc=akpm@linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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