public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: Avoid intermixing cpu dump_stack output on multi-processor systems
@ 2012-05-24 14:42 Russ Anderson
  2012-05-24 15:34 ` Frederic Weisbecker
  2012-05-29 17:53 ` Don Zickus
  0 siblings, 2 replies; 10+ messages in thread
From: Russ Anderson @ 2012-05-24 14:42 UTC (permalink / raw)
  To: linux-kernel, x86
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton,
	Greg Kroah-Hartman, Russ Anderson

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-06-04 14:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-24 14:42 [PATCH] x86: Avoid intermixing cpu dump_stack output on multi-processor systems Russ Anderson
2012-05-24 15:34 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox