locking/qrwlock: Implement queue_write_unlock() using smp_store_release()
authorWill Deacon <will.deacon@arm.com>
Thu, 6 Aug 2015 16:54:41 +0000 (17:54 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 12 Aug 2015 09:59:05 +0000 (11:59 +0200)
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>
arch/x86/include/asm/qrwlock.h
include/asm-generic/qrwlock.h

index a8810bf135ab28f9d526852d860f1b90a622d47c..c537cbb038a7687486af1b0172dabf036a5793bd 100644 (file)
@@ -2,16 +2,6 @@
 #define _ASM_X86_QRWLOCK_H
 
 #include <asm-generic/qrwlock_types.h>
-
-#ifndef CONFIG_X86_PPRO_FENCE
-#define queued_write_unlock queued_write_unlock
-static inline void queued_write_unlock(struct qrwlock *lock)
-{
-        barrier();
-        ACCESS_ONCE(*(u8 *)&lock->cnts) = 0;
-}
-#endif
-
 #include <asm-generic/qrwlock.h>
 
 #endif /* _ASM_X86_QRWLOCK_H */
index deb9e8b0eb9ef2f5a86638148e76f4c4c74cd0fe..eb673dde8879075cd43e95860e2733fe64a1d312 100644 (file)
@@ -134,21 +134,14 @@ static inline void queued_read_unlock(struct qrwlock *lock)
        atomic_sub(_QR_BIAS, &lock->cnts);
 }
 
-#ifndef queued_write_unlock
 /**
  * queued_write_unlock - release write lock of a queue rwlock
  * @lock : Pointer to queue rwlock structure
  */
 static inline void queued_write_unlock(struct qrwlock *lock)
 {
-       /*
-        * If the writer field is atomic, it can be cleared directly.
-        * Otherwise, an atomic subtraction will be used to clear it.
-        */
-       smp_mb__before_atomic();
-       atomic_sub(_QW_LOCKED, &lock->cnts);
+       smp_store_release((u8 *)&lock->cnts, 0);
 }
-#endif
 
 /*
  * Remapping rwlock architecture specific functions to the corresponding