ARCv2: spinlock/rwlock/atomics: reduce 1 instruction in exponential backoff
authorVineet Gupta <vgupta@synopsys.com>
Fri, 7 Aug 2015 07:31:39 +0000 (13:01 +0530)
committerVineet Gupta <vgupta@synopsys.com>
Fri, 7 Aug 2015 08:26:16 +0000 (13:56 +0530)
The increment of delay counter was 2 instructions:
Arithmatic Shfit Left (ASL) + set to 1 on overflow

This can be done in 1 using ROtate Left (ROL)

Suggested-by: Nigel Topham <ntopham@synopsys.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
arch/arc/include/asm/atomic.h
arch/arc/include/asm/spinlock.h

index 629dfd0a0c6b92d3888ca982f572b4094be212e1..87d18ae53115596f7b64a56a4a07a572d54c3cbd 100644 (file)
@@ -34,8 +34,7 @@
        "       mov     %[tmp], %[delay]        \n"     /* tmp = delay */       \
        "2:     brne.d  %[tmp], 0, 2b           \n"     /* while (tmp != 0) */  \
        "       sub     %[tmp], %[tmp], 1       \n"     /* tmp-- */             \
-       "       asl.f   %[delay], %[delay], 1   \n"     /* delay *= 2 */        \
-       "       mov.z   %[delay], 1             \n"     /* handle overflow */   \
+       "       rol     %[delay], %[delay]      \n"     /* delay *= 2 */        \
        "       b       1b                      \n"     /* start over */        \
        "4: ; --- success ---                   \n"                             \
 
index 7071fc0da56ab1603a95465fe0fa8ef9ab58fe48..db8c59d1eaeb760798c287a15720573ed58b9e4a 100644 (file)
@@ -260,8 +260,7 @@ static inline void arch_write_unlock(arch_rwlock_t *rw)
        "       mov     %[tmp], %[delay]        \n"     /* tmp = delay */       \
        "2:     brne.d  %[tmp], 0, 2b           \n"     /* while (tmp != 0) */  \
        "       sub     %[tmp], %[tmp], 1       \n"     /* tmp-- */             \
-       "       asl.f   %[delay], %[delay], 1   \n"     /* delay *= 2 */        \
-       "       mov.z   %[delay], 1             \n"     /* handle overflow */   \
+       "       rol     %[delay], %[delay]      \n"     /* delay *= 2 */        \
        "       b       1b                      \n"     /* start over */        \
        "                                       \n"                             \
        "4: ; --- done ---                      \n"                             \