|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] rwlock: allow arch to override read_unlock() atomic
commit 9f5584f5b6e67627d6d721ed7003469263fdeaa9
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Fri Jan 9 17:31:05 2015 +0100
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Jan 9 17:31:05 2015 +0100
rwlock: allow arch to override read_unlock() atomic
On x86, LOCK DEC is cheaper than LOCK CMPXCHG and doesn't require a
retry loop around it.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Tim Deegan <tim@xxxxxxx>
Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
xen/common/spinlock.c | 16 ++++++++++------
xen/include/asm-x86/spinlock.h | 3 +++
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c
index 13340a3..f6925ec 100644
--- a/xen/common/spinlock.c
+++ b/xen/common/spinlock.c
@@ -333,14 +333,18 @@ int _read_trylock(rwlock_t *lock)
return 1;
}
-void _read_unlock(rwlock_t *lock)
-{
- uint32_t x, y;
+#ifndef _raw_read_unlock
+# define _raw_read_unlock(l) do { \
+ uint32_t x = (l)->lock, y; \
+ while ( (y = cmpxchg(&(l)->lock, x, x - 1)) != x ) \
+ x = y; \
+} while (0)
+#endif
+inline void _read_unlock(rwlock_t *lock)
+{
preempt_enable();
- x = lock->lock;
- while ( (y = cmpxchg(&lock->lock, x, x-1)) != x )
- x = y;
+ _raw_read_unlock(lock);
}
void _read_unlock_irq(rwlock_t *lock)
diff --git a/xen/include/asm-x86/spinlock.h b/xen/include/asm-x86/spinlock.h
index 06d9b04..757e20b 100644
--- a/xen/include/asm-x86/spinlock.h
+++ b/xen/include/asm-x86/spinlock.h
@@ -31,4 +31,7 @@ static always_inline int _raw_spin_trylock(raw_spinlock_t
*lock)
return (oldval > 0);
}
+#define _raw_read_unlock(l) \
+ asm volatile ( "lock; dec%z0 %0" : "+m" ((l)->lock) :: "memory" )
+
#endif /* __ASM_SPINLOCK_H */
--
generated by git-patchbot for /home/xen/git/xen.git#master
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |