public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@openvz.org>
To: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	"Maciej W. Rozycki" <macro@linux-mips.org>,
	Don Zickus <dzickus@redhat.com>,
	"Huang, Ying" <ying.huang@intel.com>,
	lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH -tip 2/2] x86, traps: Drop nmi_reason_lock until it is really needed
Date: Tue, 01 Mar 2011 00:40:16 +0300	[thread overview]
Message-ID: <4D6C1640.5030402@openvz.org> (raw)

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@openvz.org>
---
  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)
  		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);
  }
-- 
     Cyrill

                 reply	other threads:[~2011-02-28 21:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4D6C1640.5030402@openvz.org \
    --to=gorcunov@openvz.org \
    --cc=dzickus@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macro@linux-mips.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=ying.huang@intel.com \
    /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