Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

locking/qrwlock: Implement queue_write_unlock() using smp_store_release()

Since the following commit:

536fa402221f ("compiler: Allow 1- and 2-byte smp_load_acquire() and smp_store_release()")

smp_store_release() supports byte accesses, so use that in writer unlock
and remove the conditional macro override.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Waiman Long <Waiman.Long@hp.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: paulmck@linux.vnet.ibm.com
Link: http://lkml.kernel.org/r/1438880084-18856-6-git-send-email-will.deacon@arm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Will Deacon and committed by
Ingo Molnar
2b2a85a4 f5468ffd

+1 -18
-10
arch/x86/include/asm/qrwlock.h
··· 2 2 #define _ASM_X86_QRWLOCK_H 3 3 4 4 #include <asm-generic/qrwlock_types.h> 5 - 6 - #ifndef CONFIG_X86_PPRO_FENCE 7 - #define queued_write_unlock queued_write_unlock 8 - static inline void queued_write_unlock(struct qrwlock *lock) 9 - { 10 - barrier(); 11 - ACCESS_ONCE(*(u8 *)&lock->cnts) = 0; 12 - } 13 - #endif 14 - 15 5 #include <asm-generic/qrwlock.h> 16 6 17 7 #endif /* _ASM_X86_QRWLOCK_H */
+1 -8
include/asm-generic/qrwlock.h
··· 134 134 atomic_sub(_QR_BIAS, &lock->cnts); 135 135 } 136 136 137 - #ifndef queued_write_unlock 138 137 /** 139 138 * queued_write_unlock - release write lock of a queue rwlock 140 139 * @lock : Pointer to queue rwlock structure 141 140 */ 142 141 static inline void queued_write_unlock(struct qrwlock *lock) 143 142 { 144 - /* 145 - * If the writer field is atomic, it can be cleared directly. 146 - * Otherwise, an atomic subtraction will be used to clear it. 147 - */ 148 - smp_mb__before_atomic(); 149 - atomic_sub(_QW_LOCKED, &lock->cnts); 143 + smp_store_release((u8 *)&lock->cnts, 0); 150 144 } 151 - #endif 152 145 153 146 /* 154 147 * Remapping rwlock architecture specific functions to the corresponding