Use DMB only on ARMv7
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 10 Dec 2020 21:52:30 +0000 (16:52 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 17 Dec 2020 13:28:20 +0000 (08:28 -0500)
Remove the configure time CONFIG_RCU_ARM_HAVE_DMB option and replace it
by compile time detection based on the ARM ISA version. This makes sure
we unconditionnaly use the DMB instruction only on ARMv7 where it's part
of the baseline ISA.

This will change the behavior on ARMv6 platform that possibly have this
instruction but it was probably already broken since we use the 'ISH'
option which doesn't seem to be valid on this ISA.

This will also allow sharing headers in a multi-arch environment and
reduce the build system complexity.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8e56ada55148d8e0f198c3d2e741ea414de5fef2

configure.ac
include/urcu/arch.h
include/urcu/arch/arm.h
include/urcu/config.h.in

index d1d43e645c3366e457c5d34d8475a21af5cc80e2..daa967a738a057a61dc69b5e93c9c047c4b71524 100644 (file)
@@ -21,7 +21,6 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 AC_REQUIRE_AUX_FILE([tap-driver.sh])
 
 AH_TEMPLATE([CONFIG_RCU_SMP], [Enable SMP support. With SMP support enabled, uniprocessors are also supported. With SMP support disabled, UP systems work fine, but the behavior of SMP systems is undefined.])
-AH_TEMPLATE([CONFIG_RCU_ARM_HAVE_DMB], [Use the dmb instruction if available for use on ARM.])
 AH_TEMPLATE([CONFIG_RCU_TLS], [TLS provided by the compiler.])
 AH_TEMPLATE([CONFIG_RCU_HAVE_CLOCK_GETTIME], [clock_gettime() is detected.])
 AH_TEMPLATE([CONFIG_RCU_FORCE_SYS_MEMBARRIER], [Require the operating system to support the membarrier system call for default and bulletproof flavors.])
@@ -124,24 +123,6 @@ AS_IF([test "$host_cpu" = "armv7l"],[
        AM_CFLAGS="$AM_CFLAGS -mcpu=cortex-a9 -mtune=cortex-a9 -O1"
 ])
 
-# ARM-specific checks
-AS_CASE([$host_cpu], [arm*], [
-       AC_MSG_CHECKING([for dmb instruction])
-       AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
-                               int main()
-                               {
-                                       asm volatile("dmb":::"memory");
-                                       return 0;
-                               }
-               ]])
-       ],[
-               AC_MSG_RESULT([yes])
-               AC_DEFINE([CONFIG_RCU_ARM_HAVE_DMB], [1])
-       ],[
-               AC_MSG_RESULT([no])
-       ])
-])
-
 # Search for clock_gettime
 AC_SEARCH_LIBS([clock_gettime], [rt], [
        AC_DEFINE([CONFIG_RCU_HAVE_CLOCK_GETTIME], [1])
index c4b8bc2307028a70fe62174b00d6b30fcecb6136..620743c0f68fb33dd004d3266bcf900e2a96b898 100644 (file)
@@ -41,6 +41,7 @@
  * URCU_ARCH_ALPHA : All DEC Alpha variants
  * URCU_ARCH_IA64 : All Intel Itanium variants
  * URCU_ARCH_ARM : All ARM 32 bits variants
+ *   URCU_ARCH_ARMV7 : All ARMv7 ISA variants
  * URCU_ARCH_AARCH64 : All ARM 64 bits variants
  * URCU_ARCH_MIPS : All MIPS variants
  * URCU_ARCH_NIOS2 : All Intel / Altera NIOS II variants
 #define URCU_ARCH_IA64 1
 #include <urcu/arch/ia64.h>
 
+#elif (defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7__))
+
+#define URCU_ARCH_ARMV7 1
+#define URCU_ARCH_ARM 1
+#include <urcu/arch/arm.h>
+
 #elif (defined(__arm__) || defined(__arm))
 
 #define URCU_ARCH_ARM 1
index e904b06e461cd56a6aa30fe685340cf51501193c..54ca4fabc79de65bad94009c177e73a88b37b481 100644 (file)
 extern "C" {
 #endif
 
-#ifdef CONFIG_RCU_ARM_HAVE_DMB
+/*
+ * Using DMB is faster than the builtin __sync_synchronize and this instruction is
+ * part of the baseline ARMv7 ISA.
+ */
+#ifdef URCU_ARCH_ARMV7
+
+/* For backwards compat. */
+#define CONFIG_RCU_ARM_HAVE_DMB 1
+
 /*
  * Issues full system DMB operation.
  */
@@ -44,7 +52,8 @@ extern "C" {
 #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 */
+
+#endif /* URCU_ARCH_ARMV7 */
 
 #include <stdlib.h>
 #include <sys/time.h>
index faf7817ba257f779a11af5b463973eb045dd1834..99d763a6e8ba64e7741680de3bd44bfaf53531e6 100644 (file)
@@ -5,9 +5,6 @@
    behavior of SMP systems is undefined. */
 #undef CONFIG_RCU_SMP
 
-/* Use the dmb instruction is available for use on ARM. */
-#undef CONFIG_RCU_ARM_HAVE_DMB
-
 /* TLS provided by the compiler. */
 #undef CONFIG_RCU_TLS
 
This page took 0.02706 seconds and 4 git commands to generate.