parisc: Release spinlocks using ordered store
authorJohn David Anglin <dave.anglin@bell.net>
Wed, 17 Oct 2018 01:07:59 +0000 (21:07 -0400)
committerHelge Deller <deller@gmx.de>
Wed, 17 Oct 2018 06:18:01 +0000 (08:18 +0200)
This patch updates the spin unlock code to use an ordered store with
release semanatics.  All prior accesses are guaranteed to be performed
before an ordered store is performed.

Using an ordered store is significantly faster than using the sync
memory barrier.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
Signed-off-by: Helge Deller <deller@gmx.de>
arch/parisc/include/asm/spinlock.h
arch/parisc/kernel/syscall.S

index 8a63515f03bfe3931930d094a479060815832fe6..16aec9ba2580a6dd3b3b9bfe03d29099815d2412 100644 (file)
@@ -37,8 +37,8 @@ static inline void arch_spin_unlock(arch_spinlock_t *x)
        volatile unsigned int *a;
 
        a = __ldcw_align(x);
-       mb();
-       *a = 1;
+       /* Release with ordered store. */
+       __asm__ __volatile__("stw,ma %0,0(%1)" : : "r"(1), "r"(a) : "memory");
 }
 
 static inline int arch_spin_trylock(arch_spinlock_t *x)
index f453997a7b8f219e2657cfd146660658d87c3d2a..f5f22ea9b97e683d141ba3fdbd3eedf4f3a4632a 100644 (file)
@@ -640,8 +640,7 @@ cas_action:
        sub,<>  %r28, %r25, %r0
 2:     stw     %r24, 0(%r26)
        /* Free lock */
-       sync
-       stw     %r20, 0(%sr2,%r20)
+       stw,ma  %r20, 0(%sr2,%r20)
 #if ENABLE_LWS_DEBUG
        /* Clear thread register indicator */
        stw     %r0, 4(%sr2,%r20)
@@ -655,8 +654,7 @@ cas_action:
 3:             
        /* Error occurred on load or store */
        /* Free lock */
-       sync
-       stw     %r20, 0(%sr2,%r20)
+       stw,ma  %r20, 0(%sr2,%r20)
 #if ENABLE_LWS_DEBUG
        stw     %r0, 4(%sr2,%r20)
 #endif
@@ -857,8 +855,7 @@ cas2_action:
 
 cas2_end:
        /* Free lock */
-       sync
-       stw     %r20, 0(%sr2,%r20)
+       stw,ma  %r20, 0(%sr2,%r20)
        /* Enable interrupts */
        ssm     PSW_SM_I, %r0
        /* Return to userspace, set no error */
@@ -868,8 +865,7 @@ cas2_end:
 22:
        /* Error occurred on load or store */
        /* Free lock */
-       sync
-       stw     %r20, 0(%sr2,%r20)
+       stw,ma  %r20, 0(%sr2,%r20)
        ssm     PSW_SM_I, %r0
        ldo     1(%r0),%r28
        b       lws_exit