From: "Jan Beulich" Subject: Ping: [PATCH] x86/MCE: mctelem_init() cleanup Date: Fri, 07 Mar 2014 15:12:39 +0000 Message-ID: <5319EFF70200007800121F14@nat28.tlf.novell.com> References: <5310CB4F0200007800120468@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WLwS2-0008Lv-JH for xen-devel@lists.xenproject.org; Fri, 07 Mar 2014 15:12:42 +0000 In-Reply-To: <5310CB4F0200007800120468@nat28.tlf.novell.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Christoph Egger , Jinsong Liu Cc: xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 28.02.14 at 17:45, "Jan Beulich" wrote: > The function can be __init with its caller taking care of only calling > it on the BSP. And with that all its static variables can be dropped. > > Signed-off-by: Jan Beulich > > --- a/xen/arch/x86/cpu/mcheck/mce.c > +++ b/xen/arch/x86/cpu/mcheck/mce.c > @@ -775,13 +775,15 @@ void mcheck_init(struct cpuinfo_x86 *c, > > intpose_init(); > > - mctelem_init(sizeof(struct mc_info)); > + if ( bsp ) > + { > + mctelem_init(sizeof(struct mc_info)); > + register_cpu_notifier(&cpu_nfb); > + } > > /* Turn on MCE now */ > set_in_cr4(X86_CR4_MCE); > > - if ( bsp ) > - register_cpu_notifier(&cpu_nfb); > set_poll_bankmask(c); > > return; > --- a/xen/arch/x86/cpu/mcheck/mctelem.c > +++ b/xen/arch/x86/cpu/mcheck/mctelem.c > @@ -248,25 +248,14 @@ static void mctelem_processing_release(s > } > } > > -void mctelem_init(int reqdatasz) > +void __init mctelem_init(unsigned int datasz) > { > - static int called = 0; > - static int datasz = 0, realdatasz = 0; > char *datarr; > - int i; > + unsigned int i; > > - BUG_ON(MC_URGENT != 0 || MC_NONURGENT != 1 || MC_NCLASSES != 2); > + BUILD_BUG_ON(MC_URGENT != 0 || MC_NONURGENT != 1 || MC_NCLASSES != 2); > > - /* Called from mcheck_init for all processors; initialize for the > - * first call only (no race here since the boot cpu completes > - * init before others start up). */ > - if (++called == 1) { > - realdatasz = reqdatasz; > - datasz = (reqdatasz & ~0xf) + 0x10; /* 16 byte roundup */ > - } else { > - BUG_ON(reqdatasz != realdatasz); > - return; > - } > + datasz = (datasz & ~0xf) + 0x10; /* 16 byte roundup */ > > if ((mctctl.mctc_elems = xmalloc_array(struct mctelem_ent, > MC_NENT)) == NULL || > --- a/xen/arch/x86/cpu/mcheck/mctelem.h > +++ b/xen/arch/x86/cpu/mcheck/mctelem.h > @@ -59,7 +59,7 @@ typedef enum mctelem_class { > MC_NONURGENT > } mctelem_class_t; > > -extern void mctelem_init(int); > +extern void mctelem_init(unsigned int); > extern mctelem_cookie_t mctelem_reserve(mctelem_class_t); > extern void *mctelem_dataptr(mctelem_cookie_t); > extern void mctelem_commit(mctelem_cookie_t);