mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
To: Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@elte.hu>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org
Subject: [PATCH -rt] fix sysrq+l when nmi_watchdog disabled
Date: Tue, 27 May 2008 15:45:00 -0700	[thread overview]
Message-ID: <483C8EEC.2030306@ct.jp.nec.com> (raw)

From: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>

In nmi_show_all_regs(), set nmi_show_regs for all cpus but NMI never come
to itself when nmi_watchdog is disabled. It means the kernel hangs up when
sysrq+l is issued.

Call irq_show_regs_callback() itself before calling smp_send_nmi_allbutself().

Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
---
Steven, this is a fix for what you pointed.
http://lkml.org/lkml/2008/4/28/455

 arch/x86/kernel/nmi_32.c |   51 ++++++++++++++++++++++++++++------------------
 arch/x86/kernel/nmi_64.c |   49 ++++++++++++++++++++++++++++---------------
 2 files changed, 63 insertions(+), 37 deletions(-)

diff --git a/arch/x86/kernel/nmi_32.c b/arch/x86/kernel/nmi_32.c
index d9266ea..82abc2a 100644
--- a/arch/x86/kernel/nmi_32.c
+++ b/arch/x86/kernel/nmi_32.c
@@ -325,21 +325,49 @@ extern void die_nmi(struct pt_regs *, const char *msg);
 
 int nmi_show_regs[NR_CPUS];
 
+static DEFINE_RAW_SPINLOCK(nmi_print_lock);
+
+notrace int irq_show_regs_callback(int cpu, struct pt_regs *regs)
+{
+	if (!nmi_show_regs[cpu])
+		return 0;
+
+	spin_lock(&nmi_print_lock);
+	printk(KERN_WARNING "NMI show regs on CPU#%d:\n", cpu);
+	printk(KERN_WARNING "apic_timer_irqs: %d\n",
+		per_cpu(irq_stat, cpu).apic_timer_irqs);
+	show_regs(regs);
+	spin_unlock(&nmi_print_lock);
+	nmi_show_regs[cpu] = 0;
+	return 1;
+}
+
 void nmi_show_all_regs(void)
 {
-	int i;
+	struct pt_regs *regs;
+	int i, cpu;
 
 	if (system_state == SYSTEM_BOOTING)
 		return;
 
-	printk(KERN_WARNING "nmi_show_all_regs(): start on CPU#%d.\n",
-		raw_smp_processor_id());
+	preempt_disable();
+
+	regs = get_irq_regs();
+	cpu = smp_processor_id();
+
+	printk(KERN_WARNING "nmi_show_all_regs(): start on CPU#%d.\n", cpu);
 	dump_stack();
 
 	for_each_online_cpu(i)
 		nmi_show_regs[i] = 1;
 
+	if (regs)
+		irq_show_regs_callback(cpu, regs);
+	else
+		nmi_show_regs[cpu] = 0;
+
 	smp_send_nmi_allbutself();
+	preempt_enable();
 
 	for_each_online_cpu(i) {
 		while (nmi_show_regs[i] == 1)
@@ -347,23 +375,6 @@ void nmi_show_all_regs(void)
 	}
 }
 
-static DEFINE_RAW_SPINLOCK(nmi_print_lock);
-
-notrace int irq_show_regs_callback(int cpu, struct pt_regs *regs)
-{
-	if (!nmi_show_regs[cpu])
-		return 0;
-
-	spin_lock(&nmi_print_lock);
-	printk(KERN_WARNING "NMI show regs on CPU#%d:\n", cpu);
-	printk(KERN_WARNING "apic_timer_irqs: %d\n",
-		per_cpu(irq_stat, cpu).apic_timer_irqs);
-	show_regs(regs);
-	spin_unlock(&nmi_print_lock);
-	nmi_show_regs[cpu] = 0;
-	return 1;
-}
-
 __kprobes int nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
 {
 
diff --git a/arch/x86/kernel/nmi_64.c b/arch/x86/kernel/nmi_64.c
index c802380..5e7e2b0 100644
--- a/arch/x86/kernel/nmi_64.c
+++ b/arch/x86/kernel/nmi_64.c
@@ -317,17 +317,48 @@ EXPORT_SYMBOL(touch_nmi_watchdog);
 
 int nmi_show_regs[NR_CPUS];
 
+static DEFINE_RAW_SPINLOCK(nmi_print_lock);
+
+notrace int irq_show_regs_callback(int cpu, struct pt_regs *regs)
+{
+	if (!nmi_show_regs[cpu])
+		return 0;
+
+	spin_lock(&nmi_print_lock);
+	printk(KERN_WARNING "NMI show regs on CPU#%d:\n", cpu);
+	printk(KERN_WARNING "apic_timer_irqs: %d\n", read_pda(apic_timer_irqs));
+	show_regs(regs);
+	spin_unlock(&nmi_print_lock);
+	nmi_show_regs[cpu] = 0;
+	return 1;
+}
+
 void nmi_show_all_regs(void)
 {
-	int i;
+	struct pt_regs *regs;
+	int i, cpu;
 
 	if (system_state == SYSTEM_BOOTING)
 		return;
 
+	preempt_disable();
+
+	regs = get_irq_regs();
+	cpu = smp_processor_id();
+
+	printk(KERN_WARNING "nmi_show_all_regs(): start on CPU#%d.\n", cpu);
+	dump_stack();
+
 	for_each_online_cpu(i)
 		nmi_show_regs[i] = 1;
 
+	if (regs)
+		irq_show_regs_callback(cpu, regs);
+	else
+		nmi_show_regs[cpu] = 0;
+
 	smp_send_nmi_allbutself();
+	preempt_enable();
 
 	for_each_online_cpu(i) {
 		while (nmi_show_regs[i] == 1)
@@ -335,22 +366,6 @@ void nmi_show_all_regs(void)
 	}
 }
 
-static DEFINE_RAW_SPINLOCK(nmi_print_lock);
-
-notrace int irq_show_regs_callback(int cpu, struct pt_regs *regs)
-{
-	if (!nmi_show_regs[cpu])
-		return 0;
-
-	spin_lock(&nmi_print_lock);
-	printk(KERN_WARNING "NMI show regs on CPU#%d:\n", cpu);
-	printk(KERN_WARNING "apic_timer_irqs: %d\n", read_pda(apic_timer_irqs));
-	show_regs(regs);
-	spin_unlock(&nmi_print_lock);
-	nmi_show_regs[cpu] = 0;
-	return 1;
-}
-
 int __kprobes nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
 {
 	int sum;
-- 
1.5.4.1


             reply	other threads:[~2008-05-27 22:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-27 22:45 Hiroshi Shimamoto [this message]
2008-05-27 23:36 ` Steven Rostedt

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=483C8EEC.2030306@ct.jp.nec.com \
    --to=h-shimamoto@ct.jp.nec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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®