MCS Lock: Allow architecture specific memory barrier in lock/unlock
Subsystems (2)
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.
Signed-off-by Waiman Long <[email protected]>
--- 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
@@ -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