linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: spinlock: avoid exclusive accesses on unlock() path
@ 2013-01-11 15:07 Will Deacon
  0 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2013-01-11 15:07 UTC (permalink / raw)
  To: linux-arm-kernel

When unlocking a spinlock, all we need to do is increment the owner
field of the lock. Since only one CPU can be performing an unlock()
operation for a given lock, this doesn't need to be exclusive.

This patch simplifies arch_spin_unlock to use non-exclusive accesses
when updating the owner field of the lock.

Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 arch/arm/include/asm/spinlock.h | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)

diff --git a/arch/arm/include/asm/spinlock.h b/arch/arm/include/asm/spinlock.h
index b4ca707..6220e9f 100644
--- a/arch/arm/include/asm/spinlock.h
+++ b/arch/arm/include/asm/spinlock.h
@@ -119,22 +119,8 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
 
 static inline void arch_spin_unlock(arch_spinlock_t *lock)
 {
-	unsigned long tmp;
-	u32 slock;
-
 	smp_mb();
-
-	__asm__ __volatile__(
-"	mov	%1, #1\n"
-"1:	ldrex	%0, [%2]\n"
-"	uadd16	%0, %0, %1\n"
-"	strex	%1, %0, [%2]\n"
-"	teq	%1, #0\n"
-"	bne	1b"
-	: "=&r" (slock), "=&r" (tmp)
-	: "r" (&lock->slock)
-	: "cc");
-
+	lock->tickets.owner++;
 	dsb_sev();
 }
 
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread
[parent not found: <tencent_76D135D5D379BDAB2A2436393315C6E4E807@qq.com>]
[parent not found: <tencent_5E0B19C04FA531B834205F9F@qq.com>]

end of thread, other threads:[~2018-08-08 15:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-11 15:07 [PATCH] ARM: spinlock: avoid exclusive accesses on unlock() path Will Deacon
     [not found] <tencent_76D135D5D379BDAB2A2436393315C6E4E807@qq.com>
     [not found] ` <tencent_6BF9DD7B77B1CAA95FBAEE73@qq.com>
2018-08-07  1:59   ` 马文健
2018-08-07 16:56     ` Will Deacon
     [not found] <tencent_5E0B19C04FA531B834205F9F@qq.com>
2018-08-08 15:44 ` [PATCH] ARM: spinlock: avoid exclusive accesses on unlock()path Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).