Skip to contentSkip to conversation

MCS Lock: Allow architecture specific memory barrier in lock/unlock

PATCH New Waiman Long 1 participant 1 message Nov 6, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 5/5 MCS Lock: Allow architecture specific memory barrier in lock/unlock

This patch moves the decision of what kind of memory barriers to be used in the MCS lock and unlock functions to the architecture specific layer. It also moves the actual lock/unlock code to mcs_spinlock.c file.

A full memory barrier will be used if the following macros are not defined:
1) smp_mb__before_critical_section()
2) smp_mb__after_critical_section()

For the x86 architecture, only compiler barrier will be needed.

---
 arch/x86/include/asm/barrier.h |    6 +++
 include/linux/mcs_spinlock.h   |   78 +-------------------------------------
 kernel/mcs_spinlock.c          |   81 ++++++++++++++++++++++++++++++++++++++-
 3 files changed, 86 insertions(+), 79 deletions(-)
arch/x86/include/asm/barrier.h +6 -0
index c6cd358..6d0172c 100644
@@ -92,6 +92,12 @@
 #endif
 #define smp_read_barrier_depends()	read_barrier_depends()
 #define set_mb(var, value) do { (void)xchg(&var, value); } while (0)
+
+#if !defined(CONFIG_X86_PPRO_FENCE) && !defined(CONFIG_X86_OOSTORE)
+# define smp_mb__before_critical_section()	barrier()
+# define smp_mb__after_critical_section()	barrier()
+#endif
+
 #else
 #define smp_mb()	barrier()
 #define smp_rmb()	barrier()
include/linux/mcs_spinlock.h +2 -76

89 lines not on this page · raw message

kernel/mcs_spinlock.c +78 -3

93 lines not on this page · raw message

Signature · 1 line
1.7.1