Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 155218
b: refs/heads/master
c: 3a8d178
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar committed Jul 3, 2009
1 parent f675f9b commit 4c80e8d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 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: 1fde902d52ee13ab9fab155bbae757fdf7daf0c1
refs/heads/master: 3a8d1788b37435baf6c296f4ea8beb4fa4955f44
9 changes: 0 additions & 9 deletions trunk/arch/x86/include/asm/atomic_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,6 @@ typedef struct {

#define ATOMIC64_INIT(val) { (val) }

/**
* atomic64_read - read atomic64 variable
* @ptr: pointer of type atomic64_t
*
* Atomically reads the value of @v.
* Doesn't imply a read memory barrier.
*/
#define __atomic64_read(ptr) ((ptr)->counter)

extern u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old_val, u64 new_val);

/**
Expand Down
21 changes: 15 additions & 6 deletions trunk/arch/x86/lib/atomic64_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,23 @@ EXPORT_SYMBOL(atomic64_cmpxchg);
* Atomically xchgs the value of @ptr to @new_val and returns
* the old value.
*/

u64 atomic64_xchg(atomic64_t *ptr, u64 new_val)
{
u64 old_val;
/*
* Try first with a (possibly 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, real_val = 0;

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

real_val = atomic64_cmpxchg(ptr, old_val, new_val);

} while (real_val != old_val);

return old_val;
}
Expand Down Expand Up @@ -91,13 +100,13 @@ EXPORT_SYMBOL(atomic64_read);
noinline u64 atomic64_add_return(u64 delta, atomic64_t *ptr)
{
/*
* Try first with a (probably incorrect) assumption about
* Try first with a (possibly 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;
u64 old_val, new_val, real_val = 0;

do {
old_val = real_val;
Expand Down

0 comments on commit 4c80e8d

Please sign in to comment.