Skip to contentSkip to conversation

x86, traps: Drop nmi_reason_lock until it is really needed

PATCH Superseded Cyrill Gorcunov 1 participant 1 message Feb 28, 2011 x86

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 x86, traps: Drop nmi_reason_lock until it is really needed

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.

---
 arch/x86/kernel/traps.c |   16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
arch/x86/kernel/traps.c +6 -10
Index: 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)
 		return;
 
-	/* 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
 		 */
 		reassert_nmi();
 #endif
-		raw_spin_unlock(&nmi_reason_lock);
 		return;
 	}
-	raw_spin_unlock(&nmi_reason_lock);
 
 	unknown_nmi_error(reason, regs);
 }
Signature · 1 line
    Cyrill