Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 155211
b: refs/heads/master
c: 824975e
h: refs/heads/master
i:
  155209: 971bdf0
  155207: 937a003
v: v3
  • Loading branch information
Ingo Molnar committed Jul 3, 2009
1 parent b9b5cab commit 8057048
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 69237f94e65d3d7f539f1adb98ef68685c595004
refs/heads/master: 824975ef190e7dcb77718d1cc2cb53769b16d918
15 changes: 12 additions & 3 deletions trunk/arch/x86/lib/atomic64_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,22 @@ u64 atomic64_read(atomic64_t *ptr)
*/
u64 atomic64_add_return(u64 delta, atomic64_t *ptr)
{
u64 old_val, new_val;
/*
* Try first with a (probably incorrect) assumption about
* what we have there. We'll do two loops most likely,
* but we'll get an ownership MESI transaction straight away
* instead of a read transaction followed by a
* flush-for-ownership transaction:
*/
u64 old_val, new_val, real_val = 1ULL << 32;

do {
old_val = atomic_read(ptr);
old_val = real_val;
new_val = old_val + delta;

} while (atomic64_cmpxchg(ptr, old_val, new_val) != old_val);
real_val = atomic64_cmpxchg(ptr, old_val, new_val);

} while (real_val != old_val);

return new_val;
}
Expand Down

0 comments on commit 8057048

Please sign in to comment.