On Tue, Dec 17, 2013 at 11:21 AM, Paul E. McKenney
<paulmck@xxxxxxxxxxxxxxxxxx> wrote:
Looks like xadd() is x86-specific, but this is common code. OneNote that "xadd()" has different semantics from "atomic_add_return()".
approach would be to do xadd() for other arches, another approach
would be to make .rw be an atomic_t rather than a u32. Making it
be atomic_t is probably easiest. (The cmpxchg()s would then need
to be atomic_cmpxchg().)
xadd() returns the original value, while atomic_add_return() returns
the result of the addition.
In this case, we seem to want the xadd() semantics. I guess we can use
"atomic_add_return(val,&atomic)-val" and just assume that the compiler
gets it right (with the addition and the subtraction cancelling out).
Or maybe we should have a "atomic_add_return_original()" with xadd
semantics?
Linus