From: athorlton@sgi.com
To: linux-kernel@vger.kernel.org
Cc: Alex Thorlton <athorlton@sgi.com>,
Vineet Gupta <vgupta@synopsys.com>,
Andrew Morton <akpm@linux-foundation.org>,
"David S. Miller" <davem@davemloft.net>,
Richard Kuo <rkuo@codeaurora.org>,
Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Robin Holt <holt@sgi.com>
Subject: [patch 1/2] dump_stack: serialize the output from dump_stack()
Date: Wed, 08 May 2013 16:01:03 -0500 [thread overview]
Message-ID: <20130508210144.090393535@asylum.americas.sgi.com> (raw)
These patches fix up issues with interspersed output from multiple
simultaneous calls to warn or dump_stack on multi-cpu systems.
References: <20130508210102.898396979@asylum.americas.sgi.com>
Content-Disposition: inline; filename=dump-stack-serialize.patch
This patch adds functionality to serialize the output from dump_stack() to
avoid mangling of the output when dump_stack is called simultaneously from
multiple cpus.
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Reported-by: Russ Anderson <rja@sgi.com>
Reviewed-by: Robin Holt <holt@sgi.com>
Signed-off-by: Alex Thorlton <athorlton@sgi.com>
---
The original discussion regarding this patch can be found in this thread:
[PATCH] x86: Avoid intermixing cpu dump_stack output on multi-processor systems
lib/dump_stack.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
--- linux.orig/lib/dump_stack.c
+++ linux/lib/dump_stack.c
@@ -7,6 +7,8 @@
#include <linux/export.h>
#include <linux/sched.h>
+static atomic_t dump_lock = ATOMIC_INIT(-1);
+
/**
* dump_stack - dump the current task information and its stack trace
*
@@ -14,7 +16,30 @@
*/
void dump_stack(void)
{
+ int was_locked;
+ int old;
+ int cpu;
+
+ preempt_disable();
+
+retry:
+ cpu = smp_processor_id();
+ old = atomic_cmpxchg(&dump_lock, -1, cpu);
+ if (old == -1) {
+ was_locked = 0;
+ } else if (old == cpu) {
+ was_locked = 1;
+ } else {
+ cpu_relax();
+ goto retry;
+ }
+
dump_stack_print_info(KERN_DEFAULT);
show_stack(NULL, NULL);
+
+ if (!was_locked)
+ atomic_set(&dump_lock, -1);
+
+ preempt_enable();
}
EXPORT_SYMBOL(dump_stack);
next reply other threads:[~2013-05-08 21:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-08 21:01 athorlton [this message]
2013-05-08 22:41 ` Andrew Morton
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=20130508210144.090393535@asylum.americas.sgi.com \
--to=athorlton@sgi.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=jesper.nilsson@axis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rkuo@codeaurora.org \
--cc=vgupta@synopsys.com \
/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®