From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
To: Huang Ying <ying.huang@intel.com>
Cc: Ingo Molnar <mingo@elte.hu>, "H. Peter Anvin" <hpa@zytor.com>,
Andi Kleen <ak@linux.intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH 10/10] x86, mce: move mce_log_init() into mce_cap_init()
Date: Mon, 05 Oct 2009 15:44:58 +0900 [thread overview]
Message-ID: <4AC995EA.9030103@jp.fujitsu.com> (raw)
In-Reply-To: <4AC990E1.7030708@jp.fujitsu.com>
The mce_log_init() should be able to return -ENOMEM, to abort all following
initialization in mce.c. It can be done in same style with mce_banks_init()
so I moved mce_log_init() into mce_cap_init() too.
And put __cpuinit to mce_banks_init().
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
arch/x86/kernel/cpu/mcheck/mce.c | 48 +++++++++++++++++++++++--------------
1 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 63a7820..fad3daa 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1194,19 +1194,40 @@ int mce_notify_irq(void)
}
EXPORT_SYMBOL_GPL(mce_notify_irq);
-static int mce_banks_init(void)
+static __cpuinit int mce_banks_init(void)
{
int i;
mce_banks = kzalloc(banks * sizeof(struct mce_bank), GFP_KERNEL);
if (!mce_banks)
return -ENOMEM;
+
for (i = 0; i < banks; i++) {
struct mce_bank *b = &mce_banks[i];
b->ctl = -1ULL;
b->init = 1;
}
+
+ return 0;
+}
+
+/*
+ * Initialize MCE per-CPU log buffer
+ */
+static __cpuinit int mce_log_init(void)
+{
+ int cpu;
+
+ mcelog.nr_mcelog_cpus = num_possible_cpus();
+ mcelog.mcelog_cpus = kzalloc(sizeof(void *) * num_possible_cpus(),
+ GFP_KERNEL);
+ if (!mcelog.mcelog_cpus)
+ return -ENOMEM;
+
+ for_each_possible_cpu(cpu)
+ mcelog.mcelog_cpus[cpu] = &per_cpu(mce_log_cpus, cpu);
+
return 0;
}
@@ -1233,6 +1254,7 @@ static int __cpuinit mce_cap_init(void)
/* Don't support asymmetric configurations today */
WARN_ON(banks != 0 && b != banks);
banks = b;
+
if (!mce_banks) {
int err = mce_banks_init();
@@ -1240,6 +1262,13 @@ static int __cpuinit mce_cap_init(void)
return err;
}
+ if (!mcelog.mcelog_cpus) {
+ int err = mce_log_init();
+
+ if (err)
+ return err;
+ }
+
/* Use accurate RIP reporting if available. */
if ((cap & MCG_EXT_P) && MCG_EXT_CNT(cap) >= 9)
rip_msr = MSR_IA32_MCG_EIP;
@@ -1250,22 +1279,6 @@ static int __cpuinit mce_cap_init(void)
return 0;
}
-/*
- * Initialize MCE per-CPU log buffer
- */
-static __cpuinit void mce_log_init(void)
-{
- int cpu;
-
- if (mcelog.mcelog_cpus)
- return;
- mcelog.nr_mcelog_cpus = num_possible_cpus();
- mcelog.mcelog_cpus = kzalloc(sizeof(void *) * num_possible_cpus(),
- GFP_KERNEL);
- for_each_possible_cpu(cpu)
- mcelog.mcelog_cpus[cpu] = &per_cpu(mce_log_cpus, cpu);
-}
-
static void mce_init(void)
{
mce_banks_t all_banks;
@@ -1436,7 +1449,6 @@ void __cpuinit mcheck_init(struct cpuinfo_x86 *c)
mce_disabled = 1;
return;
}
- mce_log_init();
machine_check_vector = do_machine_check;
--
1.6.4.3
next prev parent reply other threads:[~2009-10-05 6:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-18 10:20 [BUGFIX -v7] x86, MCE: Fix bugs and issues of MCE log ring buffer Huang Ying
2009-09-18 11:09 ` Ingo Molnar
2009-09-21 5:37 ` Huang Ying
2009-09-22 13:39 ` [PATCH] x86: mce: New MCE logging design Ingo Molnar
2009-10-05 6:23 ` [BUGFIX -v7] x86, MCE: Fix bugs and issues of MCE log ring buffer Hidetoshi Seto
2009-10-05 6:33 ` [PATCH 01/10] x86, mce: remove tsc handling from mce_read Hidetoshi Seto
2009-10-05 6:34 ` [PATCH 02/10] x86, mce: mce_read can check args without mutex Hidetoshi Seto
2009-10-05 6:35 ` [PATCH 03/10] x86, mce: change writer timeout in mce_read Hidetoshi Seto
2009-10-05 6:36 ` [PATCH 04/10] x86, mce: use do-while in mce_log Hidetoshi Seto
2009-10-05 6:37 ` [PATCH 05/10] x86, mce: make mce_log buffer to per-CPU, prep Hidetoshi Seto
2009-10-05 6:38 ` [PATCH 06/10] x86, mce: make mce_log buffer to per-CPU Hidetoshi Seto
2009-10-05 7:06 ` Andi Kleen
2009-10-05 7:50 ` Hidetoshi Seto
2009-10-09 1:45 ` Huang Ying
2009-10-09 5:34 ` Hidetoshi Seto
2009-10-05 6:40 ` [PATCH 07/10] x86, mce: remove for-loop in mce_log Hidetoshi Seto
2009-10-05 6:41 ` [PATCH 08/10] x86, mce: change barriers " Hidetoshi Seto
2009-10-05 6:42 ` [PATCH 09/10] x86, mce: make mce_log buffer to ring buffer Hidetoshi Seto
2009-10-05 6:44 ` Hidetoshi Seto [this message]
2009-10-05 7:07 ` [BUGFIX -v7] x86, MCE: Fix bugs and issues of MCE log " Hidetoshi Seto
2009-10-05 8:51 ` Frédéric Weisbecker
2009-10-05 15:16 ` Andi Kleen
2009-10-06 5:46 ` Hidetoshi Seto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AC995EA.9030103@jp.fujitsu.com \
--to=seto.hidetoshi@jp.fujitsu.com \
--cc=ak@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=ying.huang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).