[PATCH -tip 2/2] x86, traps: Drop nmi_reason_lock until it is reallyneeded

From: Cyrill Gorcunov
Date: Mon Feb 28 2011 - 16:40:27 EST

At moment we have only BSP apic configured to listen
for external NMIs. So there is no reason for additional
spinlock since only BSP will receive them.

Though we have UV chips which do enable external NMIs
on all cpus, but since an approach to allow retrieving
NMI reason on BSP only was worked fine previously --
I assume it still remains valid.

Also it's worth to mention that an initial idea of all this
NMI code-path poking was to make BSP hot-unpluggable but
until all others part of kernel is prepared for it (which
might take quite a time to implement) I believe we should not
lock/unlock for nothing.

Signed-off-by: Cyrill Gorcunov <gorcunov@xxxxxxxxxx>
arch/x86/kernel/traps.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

Index: linux-2.6.git/arch/x86/kernel/traps.c
--- linux-2.6.git.orig/arch/x86/kernel/traps.c
+++ linux-2.6.git/arch/x86/kernel/traps.c
@@ -84,11 +84,6 @@ EXPORT_SYMBOL_GPL(used_vectors);
static int ignore_nmis;

int unknown_nmi_panic;
- * Prevent NMI reason port (0x61) being accessed simultaneously, can
- * only be used in NMI handler.
- */
-static DEFINE_RAW_SPINLOCK(nmi_reason_lock);

static inline void conditional_sti(struct pt_regs *regs)
@@ -406,9 +401,12 @@ static notrace __kprobes void default_do
if (notify_die(DIE_NMI, "nmi", regs, 0, 2, SIGINT) == NOTIFY_STOP)

- /* Non-CPU-specific NMI: NMI sources can be processed on any CPU */
- raw_spin_lock(&nmi_reason_lock);
- reason = get_nmi_reason();
+ /*
+ * Only BSP is configured to listen and handle external NMIs.
+ * Note this implicitly orders a call to the get_nmi_reason.
+ */
+ if (!smp_processor_id())
+ reason = get_nmi_reason();

if (reason & NMI_REASON_MASK) {
if (reason & NMI_REASON_SERR)
@@ -422,10 +420,8 @@ static notrace __kprobes void default_do
- raw_spin_unlock(&nmi_reason_lock);
- raw_spin_unlock(&nmi_reason_lock);

unknown_nmi_error(reason, regs);
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/