From: Ingo Molnar <mingo@elte.hu>
To: Russ Anderson <rja@sgi.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
tglx@linutronix.de, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86: Enable NMI on all cpus on UV
Date: Mon, 22 Feb 2010 11:38:53 +0100 [thread overview]
Message-ID: <20100222103853.GA14522@elte.hu> (raw)
In-Reply-To: <20100217165049.GA26331@sgi.com>
* Russ Anderson <rja@sgi.com> wrote:
> Enable NMI on all cpus in UV system and add an NMI handler
> to dump_stack on each cpu.
>
> Signed-off-by: Russ Anderson <rja@sgi.com>
>
> ---
>
> By default on x86 all the cpus except the boot cpu have NMI
> masked off. This patch enables NMI on all cpus in UV system
> and adds an NMI handler to dump_stack on each cpu. This
> way if a system hangs we can NMI the machine and get a
> backtrace from all the cpus.
>
>
> arch/x86/include/asm/uv/uv.h | 1
> arch/x86/kernel/apic/x2apic_uv_x.c | 49 +++++++++++++++++++++++++++++++++++++
> arch/x86/kernel/smpboot.c | 2 +
> 3 files changed, 52 insertions(+)
>
> Index: linux/arch/x86/kernel/apic/x2apic_uv_x.c
> ===================================================================
> --- linux.orig/arch/x86/kernel/apic/x2apic_uv_x.c 2010-02-17 10:21:55.000000000 -0600
> +++ linux/arch/x86/kernel/apic/x2apic_uv_x.c 2010-02-17 10:32:20.000000000 -0600
> @@ -20,6 +20,7 @@
> #include <linux/cpu.h>
> #include <linux/init.h>
> #include <linux/io.h>
> +#include <linux/kdebug.h>
>
> #include <asm/uv/uv_mmrs.h>
> #include <asm/uv/uv_hub.h>
> @@ -39,6 +40,53 @@ static u64 gru_start_paddr, gru_end_padd
> int uv_min_hub_revision_id;
> EXPORT_SYMBOL_GPL(uv_min_hub_revision_id);
>
> +int uv_handle_nmi(struct notifier_block *self,
> + unsigned long reason, void *data)
> +{
> + unsigned long flags;
> + static DEFINE_SPINLOCK(uv_nmi_lock);
> +
> + if (reason != DIE_NMI_IPI)
> + return NOTIFY_OK;
> + /*
> + * Use a lock so only one cpu prints at a time
> + * to prevent intermixed output.
> + */
> + spin_lock_irqsave(&uv_nmi_lock, flags);
> + printk(KERN_INFO "NMI stack dump cpu %u:\n",
> + smp_processor_id());
> + dump_stack();
> + spin_unlock_irqrestore(&uv_nmi_lock, flags);
> +
> + return NOTIFY_STOP;
> +}
> +
> +static struct notifier_block uv_dump_stack_nmi_nb = {
> + .notifier_call = uv_handle_nmi,
> + .next = NULL,
> + .priority = 0
> +};
> +
> +void uv_register_nmi_notifier(void)
> +{
> + if (register_die_notifier(&uv_dump_stack_nmi_nb))
> + printk(KERN_WARNING "UV NMI handler failed to register\n");
> +}
> +
> +/*
> + * Called on each cpu to unmask NMI.
> + */
> +void __cpuinit uv_nmi_init(void)
> +{
> + unsigned int value;
> +
> + /*
> + * Unmask NMI on all cpus
> + */
> + value = apic_read(APIC_LVT1) | APIC_DM_NMI;
> + value &= ~APIC_LVT_MASKED;
> + apic_write(APIC_LVT1, value);
> +}
>
> static int is_GRU_range(u64 start, u64 end)
> {
> @@ -718,5 +766,6 @@ void __init uv_system_init(void)
>
> uv_cpu_init();
> uv_scir_register_cpu_notifier();
> + uv_register_nmi_notifier();
> proc_mkdir("sgi_uv", NULL);
> }
> Index: linux/arch/x86/include/asm/uv/uv.h
> ===================================================================
> --- linux.orig/arch/x86/include/asm/uv/uv.h 2010-02-17 10:21:55.000000000 -0600
> +++ linux/arch/x86/include/asm/uv/uv.h 2010-02-17 10:32:20.000000000 -0600
> @@ -11,6 +11,7 @@ struct mm_struct;
> extern enum uv_system_type get_uv_system_type(void);
> extern int is_uv_system(void);
> extern void uv_cpu_init(void);
> +extern void uv_nmi_init(void);
> extern void uv_system_init(void);
> extern const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask,
> struct mm_struct *mm,
> Index: linux/arch/x86/kernel/smpboot.c
> ===================================================================
> --- linux.orig/arch/x86/kernel/smpboot.c 2010-02-17 10:21:55.000000000 -0600
> +++ linux/arch/x86/kernel/smpboot.c 2010-02-17 10:32:20.000000000 -0600
> @@ -320,6 +320,8 @@ notrace static void __cpuinit start_seco
> unlock_vector_lock();
> ipi_call_unlock();
> per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
> + if (is_uv_system())
> + uv_nmi_init();
Instead of cramming it into the init sequence open-coded, shouldnt this be
done via the x86_platform driver mechanism?
Thanks,
Ingo
next prev parent reply other threads:[~2010-02-22 10:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-17 16:50 Russ Anderson
2010-02-22 10:38 ` Ingo Molnar [this message]
2010-02-22 22:24 ` Russ Anderson
2010-02-25 17:24 ` Russ Anderson
2010-02-26 9:22 ` Ingo Molnar
2010-02-26 16:49 ` Russ Anderson
2010-02-27 11:35 ` Ingo Molnar
2010-02-27 12:56 ` [tip:x86/pci] " tip-bot for Russ Anderson
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=20100222103853.GA14522@elte.hu \
--to=mingo@elte.hu \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rja@sgi.com \
--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
Powered by JetHome