Re: [PATCH 07/12] x86: use cmpxchg_flag() where applicable

From: H. Peter Anvin
Date: Wed Aug 24 2011 - 18:02:37 EST


On 08/24/2011 02:56 PM, Linus Torvalds wrote:
> Ok, I see nothing horrible in this series.
>
> The one reaction I have is that the cmpxchg_flag() thing returns an
> 8-bit value, but then a lot of the users end up having to extend it to
> a full "int" purely for calling convention reasons (eg I think
> 'down_write_trylock()' will have 'sete + movzl' - not a new problem,
> but since the whole point was to remove extraneous instructions and we
> no longer have the silly 'testl', it now annoys me more).
>
> So it seems a bit sad. But I guess it doesn't really matter.
>

I think it is a net lose. The most common case is probably going to be
to use it immediately, in which case we have:

cmpxchg -> sete -> compare -> conditional

versus

cmpxchg -> compare -> conditional

For doubleword cmpxchg it's another matter entirely, because doubleword
comparisons are significantly more expensive that sete + test.

So unless there is actual data showing this is better, I would like to
see this dropped for now.

-hpa
--
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/