From: "Jan Beulich" Subject: [PATCH] x86/MCE: mctelem_init() cleanup Date: Fri, 28 Feb 2014 16:45:51 +0000 Message-ID: <5310CB4F0200007800120468@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB98BF72F.2__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WJQZ9-0004X5-Ll for xen-devel@lists.xenproject.org; Fri, 28 Feb 2014 16:45:39 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Jinsong Liu , Christoph Egger List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartB98BF72F.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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,=20 =20 intpose_init(); =20 - mctelem_init(sizeof(struct mc_info)); + if ( bsp ) + { + mctelem_init(sizeof(struct mc_info)); + register_cpu_notifier(&cpu_nfb); + } =20 /* Turn on MCE now */ set_in_cr4(X86_CR4_MCE); =20 - if ( bsp ) - register_cpu_notifier(&cpu_nfb); set_poll_bankmask(c); =20 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 } } =20 -void mctelem_init(int reqdatasz) +void __init mctelem_init(unsigned int datasz) { - static int called =3D 0; - static int datasz =3D 0, realdatasz =3D 0; char *datarr; - int i; + unsigned int i; =09 - BUG_ON(MC_URGENT !=3D 0 || MC_NONURGENT !=3D 1 || MC_NCLASSES !=3D = 2); + BUILD_BUG_ON(MC_URGENT !=3D 0 || MC_NONURGENT !=3D 1 || MC_NCLASSES= !=3D 2); =20 - /* 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 =3D=3D 1) { - realdatasz =3D reqdatasz; - datasz =3D (reqdatasz & ~0xf) + 0x10; /* 16 byte roundup = */ - } else { - BUG_ON(reqdatasz !=3D realdatasz); - return; - } + datasz =3D (datasz & ~0xf) + 0x10; /* 16 byte roundup */ =20 if ((mctctl.mctc_elems =3D xmalloc_array(struct mctelem_ent, MC_NENT)) =3D=3D 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; =20 -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); --=__PartB98BF72F.2__= Content-Type: text/plain; name="x86-mctelem-init.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-mctelem-init.patch" x86/MCE: mctelem_init() cleanup=0A=0AThe function can be __init with its = caller taking care of only calling=0Ait on the BSP. And with that all its = static variables can be dropped.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/arch/x86/cpu/mcheck/mce.c=0A+++ b/xen/arch/x86/cpu= /mcheck/mce.c=0A@@ -775,13 +775,15 @@ void mcheck_init(struct cpuinfo_x86 = *c, =0A =0A intpose_init();=0A =0A- mctelem_init(sizeof(struct = mc_info));=0A+ if ( bsp )=0A+ {=0A+ mctelem_init(sizeof(struct= mc_info));=0A+ register_cpu_notifier(&cpu_nfb);=0A+ }=0A =0A = /* Turn on MCE now */=0A set_in_cr4(X86_CR4_MCE);=0A =0A- if ( bsp = )=0A- register_cpu_notifier(&cpu_nfb);=0A set_poll_bankmask(c);= =0A =0A return;=0A--- a/xen/arch/x86/cpu/mcheck/mctelem.c=0A+++ = b/xen/arch/x86/cpu/mcheck/mctelem.c=0A@@ -248,25 +248,14 @@ static void = mctelem_processing_release(s=0A }=0A }=0A =0A-void mctelem_init(int= reqdatasz)=0A+void __init mctelem_init(unsigned int datasz)=0A {=0A- = static int called =3D 0;=0A- static int datasz =3D 0, realdatasz =3D = 0;=0A char *datarr;=0A- int i;=0A+ unsigned int i;=0A = =0A- BUG_ON(MC_URGENT !=3D 0 || MC_NONURGENT !=3D 1 || MC_NCLASSES !=3D = 2);=0A+ BUILD_BUG_ON(MC_URGENT !=3D 0 || MC_NONURGENT !=3D 1 || MC_NCLASSES= !=3D 2);=0A =0A- /* Called from mcheck_init for all processors; = initialize for the=0A- * first call only (no race here since the boot = cpu completes=0A- * init before others start up). */=0A- if = (++called =3D=3D 1) {=0A- realdatasz =3D reqdatasz;=0A- = datasz =3D (reqdatasz & ~0xf) + 0x10; /* 16 byte roundup */=0A- } = else {=0A- BUG_ON(reqdatasz !=3D realdatasz);=0A- = return;=0A- }=0A+ datasz =3D (datasz & ~0xf) + 0x10; /* 16 byte = roundup */=0A =0A if ((mctctl.mctc_elems =3D xmalloc_array(struct = mctelem_ent,=0A MC_NENT)) =3D=3D NULL ||=0A--- a/xen/arch/x86/c= pu/mcheck/mctelem.h=0A+++ b/xen/arch/x86/cpu/mcheck/mctelem.h=0A@@ -59,7 = +59,7 @@ typedef enum mctelem_class {=0A MC_NONURGENT=0A } = mctelem_class_t;=0A =0A-extern void mctelem_init(int);=0A+extern void = mctelem_init(unsigned int);=0A extern mctelem_cookie_t mctelem_reserve(mcte= lem_class_t);=0A extern void *mctelem_dataptr(mctelem_cookie_t);=0A extern = void mctelem_commit(mctelem_cookie_t);=0A --=__PartB98BF72F.2__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartB98BF72F.2__=--