x86/MCE: mctelem_init() cleanup
PATCH 1/1 x86/MCE: mctelem_init() cleanup
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.
xen/arch/x86/cpu/mcheck/mce.c +5 -3
@@ -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 ;
xen/arch/x86/cpu/mcheck/mctelem.c +4 -15
@@ -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 ||
xen/arch/x86/cpu/mcheck/mctelem.h +1 -1
@@ -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 );
x86/MCE: mctelem_init() cleanup
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.
xen/arch/x86/cpu/mcheck/mce.c +5 -3
@@ -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 ;
xen/arch/x86/cpu/mcheck/mctelem.c +4 -15
@@ -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 ||
xen/arch/x86/cpu/mcheck/mctelem.h +1 -1
@@ -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 );
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 4 lines · Jan Beulich
The function can be
__initwith 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 <[email protected]>
Quoted 70 lines
xen/arch/x86/cpu/mcheck/mce.c +5
-3@@ -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 ;xen/arch/x86/cpu/mcheck/mctelem.c +4
-15@@ -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 ||xen/arch/x86/cpu/mcheck/mctelem.h +1
-1@@ -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 );
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Ping: [PATCH] x86/MCE: mctelem_init() cleanup
In reply to Jan BeulichQuoted 70 lines
Quoted 1 line
Quoted 1 line · Jan Beulich
The function can be
__initwith 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 <[email protected]>xen/arch/x86/cpu/mcheck/mce.c +5
-3@@ -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 ;xen/arch/x86/cpu/mcheck/mctelem.c +4
-15@@ -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 ||xen/arch/x86/cpu/mcheck/mctelem.h +1
-1@@ -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 );
Quoted 4 lines · Jan Beulich
The function can be
__initwith 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 <[email protected]>
Quoted 66 lines
xen/arch/x86/cpu/mcheck/mce.c +5
-3@@ -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 ;xen/arch/x86/cpu/mcheck/mctelem.c +4
-15@@ -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,xen/arch/x86/cpu/mcheck/mctelem.c +0
-0MC_NENT)) == NULL ||xen/arch/x86/cpu/mcheck/mctelem.h +1
-1@@ -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 );