Re: [PATCH 1/2] FRV: Implement atomic64_t

From: Linus Torvalds
Date: Thu Jul 02 2009 - 17:29:11 EST




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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/