diff mbox

[v2,1/4] xen/mce: make mce barriers private to their users

Message ID 20170406123343.23423-2-haozhong.zhang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Haozhong Zhang April 6, 2017, 12:33 p.m. UTC
Each of current mce barriers is actually used by only one function, so
move their definitions into their users. A static mce barrier initializer
is introduced so we can move the initialization of above mce barriers
to their definitions.

Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
---
 xen/arch/x86/cpu/mcheck/barrier.h |  7 +++++++
 xen/arch/x86/cpu/mcheck/mce.c     | 10 +++-------
 2 files changed, 10 insertions(+), 7 deletions(-)

Comments

Jan Beulich April 7, 2017, 1:46 p.m. UTC | #1
>>> On 06.04.17 at 14:33, <haozhong.zhang@intel.com> wrote:
> --- a/xen/arch/x86/cpu/mcheck/barrier.h
> +++ b/xen/arch/x86/cpu/mcheck/barrier.h
> @@ -10,6 +10,13 @@ struct mce_softirq_barrier {
>      atomic_t outgen;
>  };
>  
> +#define DEFINE_MCE_BARRIER(barrier)        \

With the parameter name changed to "name" or "sym" or some such
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan
diff mbox

Patch

diff --git a/xen/arch/x86/cpu/mcheck/barrier.h b/xen/arch/x86/cpu/mcheck/barrier.h
index 87f7550..c22321c 100644
--- a/xen/arch/x86/cpu/mcheck/barrier.h
+++ b/xen/arch/x86/cpu/mcheck/barrier.h
@@ -10,6 +10,13 @@  struct mce_softirq_barrier {
     atomic_t outgen;
 };
 
+#define DEFINE_MCE_BARRIER(barrier)        \
+    struct mce_softirq_barrier barrier = { \
+        .val    = ATOMIC_INIT(0),          \
+        .ingen  = ATOMIC_INIT(0),          \
+        .outgen = ATOMIC_INIT(0),          \
+    }
+
 /*
  * Initialize a barrier. Just set it to 0.
  */
diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c
index 11d0e23..437d155 100644
--- a/xen/arch/x86/cpu/mcheck/mce.c
+++ b/xen/arch/x86/cpu/mcheck/mce.c
@@ -174,10 +174,6 @@  void mce_need_clearbank_register(mce_need_clearbank_t cbfunc)
     mc_need_clearbank_scan = cbfunc;
 }
 
-
-static struct mce_softirq_barrier mce_inside_bar, mce_severity_bar;
-static struct mce_softirq_barrier mce_trap_bar;
-
 /*
  * mce_logout_lock should only be used in the trap handler,
  * while MCIP has not been cleared yet in the global status
@@ -453,6 +449,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 DEFINE_MCE_BARRIER(mce_trap_bar);
     struct mca_banks *bankmask = mca_allbanks;
     struct mca_banks *clear_bank = __get_cpu_var(mce_clear_banks);
     uint64_t gstatus;
@@ -1698,6 +1695,8 @@  static int mce_delayed_action(mctelem_cookie_t mctc)
 /* Softirq Handler for this MCE# processing */
 static void mce_softirq(void)
 {
+    static DEFINE_MCE_BARRIER(mce_inside_bar);
+    static DEFINE_MCE_BARRIER(mce_severity_bar);
     int cpu = smp_processor_id();
     unsigned int workcpu;
 
@@ -1764,9 +1763,6 @@  void mce_handler_init(void)
 
     /* callback register, do we really need so many callback? */
     /* mce handler data initialization */
-    mce_barrier_init(&mce_inside_bar);
-    mce_barrier_init(&mce_severity_bar);
-    mce_barrier_init(&mce_trap_bar);
     spin_lock_init(&mce_logout_lock);
     open_softirq(MACHINE_CHECK_SOFTIRQ, mce_softirq);
 }