aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-07-03 07:23:02 -0400
committerIngo Molnar <mingo@elte.hu>2009-07-03 08:42:59 -0400
commit67d7178f8fc64b7f68d7dd8a1b21dfa0d42c220c (patch)
treed14adbf73d928b9c954d8ade1a3df8c61183fd95 /arch
parent8e049ef054f1cc765f05f13e1396bb9a17c19e66 (diff)
x86: atomic64: Improve atomic64_read()
Optimize atomic64_read() as a special open-coded cmpxchg8b variant. This generates nicer code: arch/x86/lib/atomic64_32.o: text data bss dec hex filename 435 0 0 435 1b3 atomic64_32.o.before 431 0 0 431 1af atomic64_32.o.after md5: bd8ab95e69c93518578bfaf0ea3be4d9 atomic64_32.o.before.asm 2bdfd4bd1f6b7b61b7fc127aef90ce3b atomic64_32.o.after.asm Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: David Howells <dhowells@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Arnd Bergmann <arnd@arndb.de> LKML-Reference: <alpine.LFD.2.01.0907021653030.3210@localhost.localdomain> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/lib/atomic64_32.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/arch/x86/lib/atomic64_32.c b/arch/x86/lib/atomic64_32.c
index fd28fd3fb742..cd11803f9448 100644
--- a/arch/x86/lib/atomic64_32.c
+++ b/arch/x86/lib/atomic64_32.c
@@ -62,9 +62,17 @@ void atomic64_set(atomic64_t *ptr, u64 new_val)
62 */ 62 */
63u64 atomic64_read(atomic64_t *ptr) 63u64 atomic64_read(atomic64_t *ptr)
64{ 64{
65 u64 old = 1LL << 32; 65 u64 res;
66 66
67 return cmpxchg8b(&ptr->counter, old, old); 67 asm volatile(
68 "mov %%ebx, %%eax\n\t"
69 "mov %%ecx, %%edx\n\t"
70 LOCK_PREFIX "cmpxchg8b %1\n"
71 : "+A" (res)
72 : "m" (*ptr)
73 );
74
75 return res;
68} 76}
69 77
70/** 78/**