From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
To: huang ying <huang.ying.caritas@gmail.com>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Andi Kleen <ak@linux.intel.com>,
Huang Ying <ying.huang@intel.com>
Subject: [PATCH] x86, mce: cleanup mce_start()
Date: Mon, 15 Jun 2009 18:18:43 +0900 [thread overview]
Message-ID: <4A3611F3.3020200@jp.fujitsu.com> (raw)
In-Reply-To: <851fc09e0906150126x4bb003flbf099aff0eed2a66@mail.gmail.com>
[ my 02/16 should be replaced by combination of Huang's fix and this cleanup ]
Simplify interface of mce_start().
- no_way_out = mce_start(no_way_out, &order);
+ order = mce_start(&no_way_out);
Now Monarch and Subjects share same exit(return) in usual path.
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
arch/x86/kernel/cpu/mcheck/mce.c | 66 ++++++++++++++++++--------------------
1 files changed, 31 insertions(+), 35 deletions(-)
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index dda7721..739fd7e 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -691,23 +691,21 @@ static atomic_t global_nwo;
* in the entry order.
* TBD double check parallel CPU hotunplug
*/
-static int mce_start(int no_way_out, int *order)
+static int mce_start(int *no_way_out)
{
- int nwo;
+ int order;
int cpus = num_online_cpus();
u64 timeout = (u64)monarch_timeout * NSEC_PER_USEC;
- if (!timeout) {
- *order = -1;
- return no_way_out;
- }
+ if (!timeout)
+ return -1;
- atomic_add(no_way_out, &global_nwo);
+ atomic_add(*no_way_out, &global_nwo);
/*
* global_nwo should be updated before mce_callin
*/
smp_wmb();
- *order = atomic_add_return(1, &mce_callin);
+ order = atomic_add_return(1, &mce_callin);
/*
* Wait for everyone.
@@ -715,8 +713,7 @@ static int mce_start(int no_way_out, int *order)
while (atomic_read(&mce_callin) != cpus) {
if (mce_timed_out(&timeout)) {
atomic_set(&global_nwo, 0);
- *order = -1;
- return no_way_out;
+ return -1;
}
ndelay(SPINUNIT);
}
@@ -725,34 +722,34 @@ static int mce_start(int no_way_out, int *order)
* mce_callin should be read before global_nwo
*/
smp_rmb();
- /*
- * Cache the global no_way_out state.
- */
- nwo = atomic_read(&global_nwo);
- /*
- * Monarch starts executing now, the others wait.
- */
- if (*order == 1) {
+ if (order == 1) {
+ /*
+ * Monarch: Starts executing now, the others wait.
+ */
atomic_set(&mce_executing, 1);
- return nwo;
+ } else {
+ /*
+ * Subject: Now start the scanning loop one by one in
+ * the original callin order.
+ * This way when there are any shared banks it will be
+ * only seen by one CPU before cleared, avoiding duplicates.
+ */
+ while (atomic_read(&mce_executing) < order) {
+ if (mce_timed_out(&timeout)) {
+ atomic_set(&global_nwo, 0);
+ return -1;
+ }
+ ndelay(SPINUNIT);
+ }
}
/*
- * Now start the scanning loop one by one
- * in the original callin order.
- * This way when there are any shared banks it will
- * be only seen by one CPU before cleared, avoiding duplicates.
+ * Cache the global no_way_out state.
*/
- while (atomic_read(&mce_executing) < *order) {
- if (mce_timed_out(&timeout)) {
- atomic_set(&global_nwo, 0);
- *order = -1;
- return no_way_out;
- }
- ndelay(SPINUNIT);
- }
- return nwo;
+ *no_way_out = atomic_read(&global_nwo);
+
+ return order;
}
/*
@@ -871,8 +868,7 @@ void do_machine_check(struct pt_regs *regs, long error_code)
* Establish sequential order between the CPUs entering the machine
* check handler.
*/
- int order = -1;
-
+ int order;
/*
* If no_way_out gets set, there is no safe way to recover from this
* MCE. If tolerant is cranked up, we'll try anyway.
@@ -917,7 +913,7 @@ void do_machine_check(struct pt_regs *regs, long error_code)
* This way we don't report duplicated events on shared banks
* because the first one to see it will clear it.
*/
- no_way_out = mce_start(no_way_out, &order);
+ order = mce_start(&no_way_out);
for (i = 0; i < banks; i++) {
__clear_bit(i, toclear);
if (!bank[i])
--
1.6.3
next prev parent reply other threads:[~2009-06-15 9:18 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-15 8:09 [PATCH 00/16] last-minute patches for MCE .31 Hidetoshi Seto
2009-06-15 8:18 ` [PATCH 01/16] x86, mce: don't init timer if !mce_available Hidetoshi Seto
2009-06-15 8:19 ` [PATCH 02/16] x86, mce: call-in should be after updating global_nwo Hidetoshi Seto
2009-06-15 8:26 ` huang ying
2009-06-15 8:40 ` Hidetoshi Seto
2009-06-15 9:18 ` Hidetoshi Seto [this message]
2009-06-15 8:20 ` [PATCH 03/16] x86, mce: add __read_mostly Hidetoshi Seto
2009-06-15 8:20 ` [PATCH 04/16] x86, mce: rename static variables around trigger Hidetoshi Seto
2009-06-15 8:21 ` [PATCH 05/16] x86, mce: sysfs entries for new options Hidetoshi Seto
2009-06-15 8:22 ` [PATCH 06/16] x86, mce: unify mce.h Hidetoshi Seto
2009-06-15 8:22 ` [PATCH 07/16] x86, mce: make mce_disabled boolean Hidetoshi Seto
2009-06-15 8:23 ` [PATCH 08/16] x86, mce: unify smp_thermal_interrupt, prepare p4 Hidetoshi Seto
2009-06-15 8:24 ` [PATCH 09/16] x86, mce: unify smp_thermal_interrupt, prepare mce_intel_64 Hidetoshi Seto
2009-06-15 8:24 ` [PATCH 10/16] x86, mce: unify smp_thermal_interrupt, prepare Hidetoshi Seto
2009-06-15 8:25 ` [PATCH 11/16] x86, mce: unify smp_thermal_interrupt Hidetoshi Seto
2009-06-15 8:26 ` [PATCH 12/16] x86, mce: squash mce_intel.c into therm_throt.c Hidetoshi Seto
2009-06-18 5:49 ` huang ying
2009-06-18 7:31 ` Hidetoshi Seto
2009-06-18 8:00 ` huang ying
2009-06-18 13:59 ` H. Peter Anvin
2009-06-18 13:56 ` H. Peter Anvin
2009-06-15 8:26 ` [PATCH 13/16] x86, mce: remove intel_set_thermal_handler() Hidetoshi Seto
2009-06-15 8:27 ` [PATCH 14/16] x86, mce: remove therm_throt.h Hidetoshi Seto
2009-06-15 8:27 ` [PATCH 15/16] x86, mce: mce.h cleanup Hidetoshi Seto
2009-06-15 8:28 ` [PATCH 16/16] x86, mce: rename 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=4A3611F3.3020200@jp.fujitsu.com \
--to=seto.hidetoshi@jp.fujitsu.com \
--cc=ak@linux.intel.com \
--cc=hpa@zytor.com \
--cc=huang.ying.caritas@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--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