* [PATCH] x86/MCE: mctelem_init() cleanup
@ 2014-02-28 16:45 Jan Beulich
2014-02-28 17:40 ` Andrew Cooper
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jan Beulich @ 2014-02-28 16:45 UTC (permalink / raw)
To: xen-devel; +Cc: Jinsong Liu, Christoph Egger
[-- Attachment #1: Type: text/plain, Size: 2120 bytes --]
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 <jbeulich@suse.com>
--- 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);
[-- Attachment #2: x86-mctelem-init.patch --]
[-- Type: text/plain, Size: 2149 bytes --]
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.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- 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);
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/MCE: mctelem_init() cleanup
2014-02-28 16:45 [PATCH] x86/MCE: mctelem_init() cleanup Jan Beulich
@ 2014-02-28 17:40 ` Andrew Cooper
2014-03-07 15:12 ` Ping: " Jan Beulich
2014-03-08 14:03 ` Liu, Jinsong
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2014-02-28 17:40 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1.1: Type: text/plain, Size: 2420 bytes --]
On 28/02/14 16: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 <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper@citrix.com>
>
> --- 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);
>
>
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
[-- Attachment #1.2: Type: text/html, Size: 3221 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Ping: [PATCH] x86/MCE: mctelem_init() cleanup
2014-02-28 16:45 [PATCH] x86/MCE: mctelem_init() cleanup Jan Beulich
2014-02-28 17:40 ` Andrew Cooper
@ 2014-03-07 15:12 ` Jan Beulich
2014-03-08 14:03 ` Liu, Jinsong
2 siblings, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2014-03-07 15:12 UTC (permalink / raw)
To: Christoph Egger, Jinsong Liu; +Cc: xen-devel
>>> On 28.02.14 at 17:45, "Jan Beulich" <JBeulich@suse.com> 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 <jbeulich@suse.com>
>
> --- 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);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/MCE: mctelem_init() cleanup
2014-02-28 16:45 [PATCH] x86/MCE: mctelem_init() cleanup Jan Beulich
2014-02-28 17:40 ` Andrew Cooper
2014-03-07 15:12 ` Ping: " Jan Beulich
@ 2014-03-08 14:03 ` Liu, Jinsong
2 siblings, 0 replies; 4+ messages in thread
From: Liu, Jinsong @ 2014-03-08 14:03 UTC (permalink / raw)
To: Jan Beulich, xen-devel; +Cc: Christoph Egger
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 <jbeulich@suse.com>
Reviewed-by: Liu Jinsong <jinsong.liu@intel.com>
>
> --- 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);
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-08 14:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-28 16:45 [PATCH] x86/MCE: mctelem_init() cleanup Jan Beulich
2014-02-28 17:40 ` Andrew Cooper
2014-03-07 15:12 ` Ping: " Jan Beulich
2014-03-08 14:03 ` Liu, Jinsong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).