diff options
-rw-r--r-- | arch/x86/lib/atomic64_32.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/arch/x86/lib/atomic64_32.c b/arch/x86/lib/atomic64_32.c index 5fc1e2caa544..61959627e1e1 100644 --- a/arch/x86/lib/atomic64_32.c +++ b/arch/x86/lib/atomic64_32.c | |||
@@ -76,13 +76,22 @@ u64 atomic64_read(atomic64_t *ptr) | |||
76 | */ | 76 | */ |
77 | u64 atomic64_add_return(u64 delta, atomic64_t *ptr) | 77 | u64 atomic64_add_return(u64 delta, atomic64_t *ptr) |
78 | { | 78 | { |
79 | u64 old_val, new_val; | 79 | /* |
80 | * Try first with a (probably incorrect) assumption about | ||
81 | * what we have there. We'll do two loops most likely, | ||
82 | * but we'll get an ownership MESI transaction straight away | ||
83 | * instead of a read transaction followed by a | ||
84 | * flush-for-ownership transaction: | ||
85 | */ | ||
86 | u64 old_val, new_val, real_val = 1ULL << 32; | ||
80 | 87 | ||
81 | do { | 88 | do { |
82 | old_val = atomic_read(ptr); | 89 | old_val = real_val; |
83 | new_val = old_val + delta; | 90 | new_val = old_val + delta; |
84 | 91 | ||
85 | } while (atomic64_cmpxchg(ptr, old_val, new_val) != old_val); | 92 | real_val = atomic64_cmpxchg(ptr, old_val, new_val); |
93 | |||
94 | } while (real_val != old_val); | ||
86 | 95 | ||
87 | return new_val; | 96 | return new_val; |
88 | } | 97 | } |