[PATCH 08/10] x86, mce: change barriers in mce_log

From: Hidetoshi Seto
Date: Mon Oct 05 2009 - 02:43:07 EST


Long time ago, smp_wmb() was replaced to wmb() by following commit:
commit 7644143cd6f7e029f3a8ea64f5fb0ab33ec39f72
Author: Mike Waychison <mikew@xxxxxxxxxx>
Date: Fri Sep 30 00:01:27 2005 +0200
[PATCH] x86_64: Fix mce_log
> AK: turned the smp_wmbs into true wmbs to make sure they are not
> reordered by the compiler on UP.

Change them back to original form, and put comments.

(This piece originates from Huang's patch, titled:
"x86, MCE: Fix bugs and issues of MCE log ring buffer")

Originally-From: Huang Ying <ying.huang@xxxxxxxxx>
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@xxxxxxxxxxxxxx>
---
arch/x86/kernel/cpu/mcheck/mce.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 87b2e29..655915b 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -141,8 +141,9 @@ void mce_log(struct mce *mce)
struct mce_log_cpu *mcelog_cpu = &__get_cpu_var(mce_log_cpus);
unsigned next, entry;

+ /* mce->finished must be set to 0 before written to buffer */
mce->finished = 0;
- wmb();
+ smp_wmb();

do {
entry = mcelog_cpu->next;
@@ -161,9 +162,12 @@ void mce_log(struct mce *mce)

memcpy(mcelog_cpu->entry + entry, mce, sizeof(struct mce));

- wmb();
+ /* ".finished" of MCE record in buffer must be set after copy */
+ smp_wmb();
mcelog_cpu->entry[entry].finished = 1;
- wmb();
+
+ /* bit 0 of notify_user should be set after finished be set */
+ smp_wmb();
mce->finished = 1;
set_bit(0, &mce_need_notify);
}
--
1.6.4.3


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/