diff options
author | Nick Piggin <npiggin@suse.de> | 2006-03-23 06:01:02 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-23 10:38:17 -0500 |
commit | 0b2fcfdb8b4e7e379192f24ea2203163ddf5df1d (patch) | |
tree | 1f3995e41ab12ff76e737389e0b59a40c0c73668 /include/asm-m68k | |
parent | 713729e8b993cb880225e2ced50a3f5ac05c2b3f (diff) |
[PATCH] atomic: add_unless cmpxchg optimise
Without branch hints, the very unlikely chance of the loop repeating due to
cmpxchg failure is unrolled with gcc-4 that I have tested.
Improve this for architectures with a native cas/cmpxchg. llsc archs
should try to implement this natively.
Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: Andi Kleen <ak@muc.de>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-m68k')
-rw-r--r-- | include/asm-m68k/atomic.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/include/asm-m68k/atomic.h b/include/asm-m68k/atomic.h index 862e497c2645..732d696d31a6 100644 --- a/include/asm-m68k/atomic.h +++ b/include/asm-m68k/atomic.h | |||
@@ -175,8 +175,14 @@ static inline void atomic_set_mask(unsigned long mask, unsigned long *v) | |||
175 | ({ \ | 175 | ({ \ |
176 | int c, old; \ | 176 | int c, old; \ |
177 | c = atomic_read(v); \ | 177 | c = atomic_read(v); \ |
178 | while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \ | 178 | for (;;) { \ |
179 | if (unlikely(c == (u))) \ | ||
180 | break; \ | ||
181 | old = atomic_cmpxchg((v), c, c + (a)); \ | ||
182 | if (likely(old == c)) \ | ||
183 | break; \ | ||
179 | c = old; \ | 184 | c = old; \ |
185 | } \ | ||
180 | c != (u); \ | 186 | c != (u); \ |
181 | }) | 187 | }) |
182 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) | 188 | #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) |