]> xenbits.xensource.com Git - people/aperard/xtf.git/commitdiff
barrier: Use LOCK ADD rather than MFENCE
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 5 Oct 2020 17:47:09 +0000 (18:47 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Sat, 10 Oct 2020 08:55:47 +0000 (09:55 +0100)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
arch/x86/include/arch/barrier.h

index 4c439af98011dd5175fbda42fc88a54ebfad8111..3645a2ec39b4772ce94e6b1d9a1760ea17c73bc6 100644 (file)
  * the point of view of program order, reads may not be reordered with respect
  * to other reads, and writes may not be reordered with respect to other
  * writes, causing smp_rmb() and smp_wmb() to degrade to simple compiler
- * barriers.  smp_mb() however does need to be an mfence instruction, as reads
- * are permitted to be reordered ahead of non-aliasing writes.
+ * barriers.
+ *
+ * smp_mb() however does need to provide real ordering, as reads are permitted
+ * to be reordered ahead of non-aliasing writes.
  */
 
 #include <xtf/compiler.h>
 #define rmb()     __asm__ __volatile__ ("lfence" ::: "memory")
 #define wmb()     __asm__ __volatile__ ("sfence" ::: "memory")
 
-#define smp_mb()  mb()
+#ifdef __i386__
+#define smp_mb()  __asm__ __volatile__ ("lock addl $0, -4(%%esp)" ::: "memory");
+#else
+#define smp_mb()  __asm__ __volatile__ ("lock addl $0, -4(%%rsp)" ::: "memory");
+#endif
 #define smp_rmb() barrier()
 #define smp_wmb() barrier()