summaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/spinlock.h
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-01-25 12:50:13 -0800
committerIngo Molnar <mingo@elte.hu>2009-01-26 14:06:36 +0100
commit2d4d57db692ea790e185656516e6ebe8791f1788 (patch)
treef7ad21dbcb4d5de2f0eb63024c1b5f1bf5321d76 /arch/x86/include/asm/spinlock.h
parent7106a5ab89c50c6b5aadea0850b40323804a922d (diff)
downloadlinux-0-day-2d4d57db692ea790e185656516e6ebe8791f1788.tar.gz
linux-0-day-2d4d57db692ea790e185656516e6ebe8791f1788.tar.xz
x86: micro-optimize __raw_read_trylock()
The current version of __raw_read_trylock starts with decrementing the lock and read its new value as a separate operation after that. That makes 3 dereferences (read, write (after sub), read) whereas a single atomic_dec_return does only two pointers dereferences (read, write). Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/include/asm/spinlock.h')
-rw-r--r--arch/x86/include/asm/spinlock.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index d17c91981da2f..4d3dcc51cacdf 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -329,8 +329,7 @@ static inline int __raw_read_trylock(raw_rwlock_t *lock)
{
atomic_t *count = (atomic_t *)lock;
- atomic_dec(count);
- if (atomic_read(count) >= 0)
+ if (atomic_dec_return(count) >= 0)
return 1;
atomic_inc(count);
return 0;