All of lore.kernel.org
 help / color / mirror / Atom feed
From: Haozhong Zhang <haozhong.zhang@intel.com>
To: xen-devel@lists.xen.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Haozhong Zhang <haozhong.zhang@intel.com>
Subject: [PATCH 2/2] xen/mce: fix static variable 'severity_cpu'
Date: Thu,  6 Apr 2017 12:55:37 +0800	[thread overview]
Message-ID: <20170406045537.1573-2-haozhong.zhang@intel.com> (raw)
In-Reply-To: <20170406045537.1573-1-haozhong.zhang@intel.com>

1. Distinguish 'severity_cpu' used in mcheck_cmn_handler() and
   mce_softirq(), which should be different variables. Otherwise, they
   may interfere with each other if MC# comes during mce_softirq().
2. Always (re-)initialize 'severity_cpu' to clear historical information.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
---
 xen/arch/x86/cpu/mcheck/mce.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c
index 7618120..d9ab80a 100644
--- a/xen/arch/x86/cpu/mcheck/mce.c
+++ b/xen/arch/x86/cpu/mcheck/mce.c
@@ -177,7 +177,7 @@ void mce_need_clearbank_register(mce_need_clearbank_t cbfunc)
 
 static struct mce_softirq_barrier mce_inside_bar, mce_severity_bar;
 static struct mce_softirq_barrier mce_trap_bar;
-static struct mce_softirq_barrier mce_handler_init_bar;
+static struct mce_softirq_barrier mce_handler_init_bar, mce_softirq_init_bar;
 
 /*
  * mce_logout_lock should only be used in the trap handler,
@@ -187,8 +187,6 @@ static struct mce_softirq_barrier mce_handler_init_bar;
  */
 static DEFINE_SPINLOCK(mce_logout_lock);
 
-static atomic_t severity_cpu = ATOMIC_INIT(-1);
-
 const struct mca_error_handler *__read_mostly mce_dhandlers;
 const struct mca_error_handler *__read_mostly mce_uhandlers;
 unsigned int __read_mostly mce_dhandler_num;
@@ -452,7 +450,7 @@ static int mce_urgent_action(const struct cpu_user_regs *regs,
 /* Shared #MC handler. */
 void mcheck_cmn_handler(const struct cpu_user_regs *regs)
 {
-    static atomic_t found_error;
+    static atomic_t severity_cpu, found_error;
     static cpumask_t mce_fatal_cpus;
     struct mca_banks *bankmask = mca_allbanks;
     struct mca_banks *clear_bank = __get_cpu_var(mce_clear_banks);
@@ -461,6 +459,7 @@ void mcheck_cmn_handler(const struct cpu_user_regs *regs)
     struct mca_summary bs;
 
     mce_barrier_enter(&mce_handler_init_bar);
+    atomic_set(&severity_cpu, -1);
     atomic_set(&found_error, 0);
     cpumask_clear(&mce_fatal_cpus);
     mce_barrier_exit(&mce_handler_init_bar);
@@ -1704,11 +1703,16 @@ static int mce_delayed_action(mctelem_cookie_t mctc)
 /* Softirq Handler for this MCE# processing */
 static void mce_softirq(void)
 {
+    static atomic_t severity_cpu;
     int cpu = smp_processor_id();
     unsigned int workcpu;
 
     mce_printk(MCE_VERBOSE, "CPU%d enter softirq\n", cpu);
 
+    mce_barrier_enter(&mce_softirq_init_bar);
+    atomic_set(&severity_cpu, -1);
+    mce_barrier_exit(&mce_softirq_init_bar);
+
     mce_barrier_enter(&mce_inside_bar);
 
     /*
@@ -1774,6 +1778,7 @@ void mce_handler_init(void)
     mce_barrier_init(&mce_severity_bar);
     mce_barrier_init(&mce_trap_bar);
     mce_barrier_init(&mce_handler_init_bar);
+    mce_barrier_init(&mce_softirq_init_bar);
     spin_lock_init(&mce_logout_lock);
     open_softirq(MACHINE_CHECK_SOFTIRQ, mce_softirq);
 }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-04-06  4:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-06  4:55 [PATCH 1/2] xen/mce: fix static variables 'found_error' and 'mce_fatal_cpus' Haozhong Zhang
2017-04-06  4:55 ` Haozhong Zhang [this message]
2017-04-06  8:06   ` [PATCH 2/2] xen/mce: fix static variable 'severity_cpu' Jan Beulich
2017-04-06  8:49     ` Haozhong Zhang
2017-04-06  9:18       ` Jan Beulich
2017-04-06  7:54 ` [PATCH 1/2] xen/mce: fix static variables 'found_error' and 'mce_fatal_cpus' Jan Beulich
2017-04-06  8:49   ` Haozhong Zhang
2017-04-06  9:17     ` Jan Beulich

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=20170406045537.1573-2-haozhong.zhang@intel.com \
    --to=haozhong.zhang@intel.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xen.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.