From: Avi Kivity <avi@qumranet.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, Avi Kivity <avi@qumranet.com>
Subject: [PATCH] sysrq: add a show-stacktrace-on-all-cpus command
Date: Sun, 29 Jul 2007 13:29:26 +0300 [thread overview]
Message-ID: <11857049662730-git-send-email-avi@qumranet.com> (raw)
If a cpu is spinning in the kernel but still responding to interrupts,
pressing sysrq-y will show you where it's spinning.
Signed-off-by: Avi Kivity <avi@qumranet.com>
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 39cc318..1dda709 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -45,6 +45,8 @@ int __read_mostly __sysrq_enabled = 1;
static int __read_mostly sysrq_always_enabled;
+static spinlock_t show_stack_lock = SPIN_LOCK_UNLOCKED;
+
int sysrq_on(void)
{
return __sysrq_enabled || sysrq_always_enabled;
@@ -309,6 +311,26 @@ static struct sysrq_key_op sysrq_unrt_op = {
.enable_mask = SYSRQ_ENABLE_RTNICE,
};
+static void show_cpu_stack(void *garbage)
+{
+ spin_lock(&show_stack_lock);
+ printk("CPU%d stacktrace:\n", raw_smp_processor_id());
+ dump_stack();
+ sysrq_handle_showregs(0, NULL);
+ spin_unlock(&show_stack_lock);
+}
+
+static void sysrq_show_stacks(int key, struct tty_struct *tty)
+{
+ on_each_cpu(show_cpu_stack, NULL, 0, 1);
+}
+
+static struct sysrq_key_op sysrq_show_stacks_op = {
+ .handler = sysrq_show_stacks,
+ .help_msg = "stacktraces-on-all-cpus(Y)",
+ .action_msg = "Stack traces on all cpus",
+};
+
/* Key Operations table and lock */
static DEFINE_SPINLOCK(sysrq_key_table_lock);
@@ -356,7 +378,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {
&sysrq_showstate_blocked_op, /* w */
/* x: May be registered on ppc/powerpc for xmon */
NULL, /* x */
- NULL, /* y */
+ &sysrq_show_stacks_op, /* y */
NULL /* z */
};
next reply other threads:[~2007-07-29 10:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-29 10:29 Avi Kivity [this message]
2007-07-30 21:09 ` Andrew Morton
2007-07-31 3:36 ` Avi Kivity
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=11857049662730-git-send-email-avi@qumranet.com \
--to=avi@qumranet.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®