atomics: introduce smp_mb__[after|before]_atomic() barriers
authorJuergen Gross <jgross@suse.com>
Thu, 26 Mar 2020 11:42:19 +0000 (12:42 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 26 Mar 2020 11:42:19 +0000 (12:42 +0100)
When using atomic variables for synchronization barriers are needed
to ensure proper data serialization. Introduce smp_mb__before_atomic()
and smp_mb__after_atomic() as in the Linux kernel for that purpose.

Use the same definitions as in the Linux kernel.

Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <jgrall@amazon.com>
xen/include/asm-arm/system.h
xen/include/asm-x86/system.h

index e5d062667ddb1076e59a709965d283aaf9331638..65d5c8e423d72e3d2ba105a30a0d2dbc4001c100 100644 (file)
@@ -30,6 +30,9 @@
 
 #define smp_wmb()       dmb(ishst)
 
+#define smp_mb__before_atomic()    smp_mb()
+#define smp_mb__after_atomic()     smp_mb()
+
 /*
  * This is used to ensure the compiler did actually allocate the register we
  * asked it for some inline assembly sequences.  Apparently we can't trust
index 069f422f0dd5e13151dd00961f857dae02718d1c..7e5891f3dfafbfec923cea31fdaa056e55c5c5ca 100644 (file)
@@ -233,6 +233,9 @@ static always_inline unsigned long __xadd(
 #define set_mb(var, value) do { xchg(&var, value); } while (0)
 #define set_wmb(var, value) do { var = value; smp_wmb(); } while (0)
 
+#define smp_mb__before_atomic()    do { } while (0)
+#define smp_mb__after_atomic()     do { } while (0)
+
 /**
  * array_index_mask_nospec() - generate a mask that is ~0UL when the
  *      bounds check succeeds and 0 otherwise