[PATCH] percpu-rwsem: use barrier in unlock path

From: Mikulas Patocka
Date: Tue Oct 16 2012 - 19:30:44 EST


Hi

When I read my patch 62ac665ff9fc07497ca524bd20d6a96893d11071 again, it
turns out that it is missing a barrier in percpu_up_write. Please apply
this.

Mikulas

---

percpu-rwsem: use barrier in unlock path

Fix missing barrier in patch 62ac665ff9fc07497ca524bd20d6a96893d11071.

The lock is considered unlocked when p->locked is set to false.
Use barrier prevent reordering of operations around p->locked.

Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx>

---
include/linux/percpu-rwsem.h | 9 +++++++++
1 file changed, 9 insertions(+)

Index: linux-3.6.2-fast/include/linux/percpu-rwsem.h
===================================================================
--- linux-3.6.2-fast.orig/include/linux/percpu-rwsem.h 2012-10-17 01:17:55.000000000 +0200
+++ linux-3.6.2-fast/include/linux/percpu-rwsem.h 2012-10-17 01:21:46.000000000 +0200
@@ -66,6 +66,15 @@ static inline void percpu_down_write(str

static inline void percpu_up_write(struct percpu_rw_semaphore *p)
{
+ /*
+ * The lock is considered unlocked when p->locked is set to false.
+ * Use barrier prevent reordering of operations around p->locked.
+ */
+#if defined(CONFIG_X86) && (!defined(CONFIG_X86_PPRO_FENCE) && !defined(CONFIG_X86_OOSTORE))
+ barrier();
+#else
+ smp_mb();
+#endif
p->locked = false;
mutex_unlock(&p->mtx);
}

--
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/