Skip to contentSkip to conversation

ARM32: use dmb ish (inner shareable domain) for smp barriers

RFC PATCH New Mathieu Desnoyers 1 participant 2 messages Dec 5, 2016 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

RFC PATCH 2/3 Cleanup: remove cmm_wmb() from rcu_xchg_pointer and rcu_cmpxchg_pointer

Both rcu_xchg_pointer() and rcu_cmpxchg_pointer() imply both release and acquire barriers. Therefore, the extra cmm_wmb() is redundant and can be removed.

---
 include/urcu/static/urcu-pointer.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
include/urcu/static/urcu-pointer.h +4 -6
index 28333c5..6e120fc 100644
@@ -79,6 +79,8 @@ extern "C" {
  * using synchronize_rcu(). If fails (unexpected value), returns old (which
  * should not be freed !).
  *
+ * uatomic_cmpxchg() acts as both release and acquire barriers.
+ *
  * This macro is less than 10 lines long.  The intent is that this macro
  * meets the 10-line criterion in LGPL, allowing this function to be
  * expanded directly in non-LGPL code.
@@ -88,9 +90,6 @@ extern "C" {
 	({								\
 		__typeof__(*p) _________pold = (old);			\
 		__typeof__(*p) _________pnew = (_new);			\
-		if (!__builtin_constant_p(_new) ||			\
-		    ((_new) != NULL))					\
-			cmm_wmb();						\
 		uatomic_cmpxchg(p, _________pold, _________pnew);	\
 	})
 
@@ -99,6 +98,8 @@ extern "C" {
  * pointer to the data structure, which can be safely freed after waiting for a
  * quiescent state using synchronize_rcu().
  *
+ * uatomic_xchg() acts as both release and acquire barriers.
+ *
  * This macro is less than 10 lines long.  The intent is that this macro
  * meets the 10-line criterion in LGPL, allowing this function to be
  * expanded directly in non-LGPL code.
@@ -107,9 +108,6 @@ extern "C" {
 	__extension__					\
 	({						\
 		__typeof__(*p) _________pv = (v);	\
-		if (!__builtin_constant_p(v) ||		\
-		    ((v) != NULL))			\
-			cmm_wmb();				\
 		uatomic_xchg(p, _________pv);		\
 	})
 
Signature · 6 lines
2.1.4

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
#2 lore raw

RFC PATCH 3/3 ARM32: use dmb ish (inner shareable domain) for smp barriers

In reply to a message not in the archive

Based on https://gcc.gnu.org/ml/gcc-patches/2014-11/msg01272.html:

From: Ramana Radhakrishnan <[email protected]>:

"Hans Boehm pointed out that we were using dmb sy instead of dmb ish. Given that the ARM-ARM says that the inner shareability domain is really the one that contains all PE's controlled by a single hypervisor or operating system, it would be safe to replace all dmb sy's with dmb ish's. "

Keep full system barriers for cmm_mb()/cmm_rmb()/cmm_wmb().

---
 include/urcu/arch/arm.h | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
include/urcu/arch/arm.h +13 -3
index 5cbca7d..cb8f28d 100644
@@ -31,9 +31,19 @@ extern "C" {
 #endif
 
 #ifdef CONFIG_RCU_ARM_HAVE_DMB
-#define cmm_mb()	__asm__ __volatile__ ("dmb":::"memory")
-#define cmm_rmb()	__asm__ __volatile__ ("dmb":::"memory")
-#define cmm_wmb()	__asm__ __volatile__ ("dmb":::"memory")
+/*
+ * Issues full system DMB operation.
+ */
+#define cmm_mb()	__asm__ __volatile__ ("dmb sy":::"memory")
+#define cmm_rmb()	__asm__ __volatile__ ("dmb sy":::"memory")
+#define cmm_wmb()	__asm__ __volatile__ ("dmb sy":::"memory")
+
+/*
+ * Issues DMB operation only to the inner shareable domain.
+ */
+#define cmm_smp_mb()	__asm__ __volatile__ ("dmb ish":::"memory")
+#define cmm_smp_rmb()	__asm__ __volatile__ ("dmb ish":::"memory")
+#define cmm_smp_wmb()	__asm__ __volatile__ ("dmb ish":::"memory")
 #endif /* CONFIG_RCU_ARM_HAVE_DMB */
 
 #include <stdlib.h>
Signature · 6 lines
2.1.4

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev