Messages in this thread |  | | | Date | Thu, 2 Jul 2009 14:28:23 -0700 (PDT) | | From | Linus Torvalds <> | | Subject | Re: [PATCH 1/2] FRV: Implement atomic64_t |
On Thu, 2 Jul 2009, Eric Dumazet wrote: > > Using a fixed initial value (instead of __atomic64_read()) is even faster, > it apparently permits cpu to use an appropriate bus transaction.
Yeah, I guess it does a "read-for-write-ownership" and allows the thing to be done as a single cache transaction.
If we read it first, it will first get the cacheline for shared-read, and then the cmpxchg8b will need to turn it from shared to exclusive.
Of course, the _optimal_ situation would be if the cmpxchg8b didn't actually do the write at all when the value matches (and all cores could just keep it shared), but I guess that's not going to happen.
Too bad there is no pure 8-byte read op. Using MMX has too many downsides.
Btw, your numbers imply that for the atomic64_add_return(), we really would be much better off not reading the original value at all. Again, in that case, we really do want the "read-for-write-ownership" cache transaction, not a read.
Linus
|  |