Re: [PATCH] x86 rwsem optimization extreme

H. Peter Anvin
2010-02-17T23:30:35Z

On 02/17/2010 02:10 PM, Linus Torvalds wrote:
>
> The cost of 'adc' may happen to be identical in this case, but I suspect
> you didn't test on UP, where the 'lock' prefix goes away. An unlocked
> 'add' tends to be faster than an unlocked 'adc'.
>
> (It's possible that some micro-architectures don't care, since it's a
> memory op, and they can see that 'C' is set. But it's a fragile assumption
> that it would always be ok).
>

FWIW, I don't know of any microarchitecture where adc is slower than
add, *as long as* the setup time for the CF flag is already used up.
However, as I already commented, I don't think this is worth it. This
inline appears to only be instantiated once, and as such, it takes a
whopping six bytes across the entire kernel.

-hpa