On Wed, Sep 11, 2013 at 7:20 PM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote: > > I split the thing up into two macros GEN_UNARY_RMWcc and > GEN_BINARY_RMWcc which ends up being more readable as well as smaller > code overall. Yes, that looks like the right abstraction level. Powerful without being complicated. > I also attempted to convert asm/bitops.h, although I'm not sure it'll > compile right with older GCCs due to the comment near BITOP_ADDR() Actually, since you now have that memory clobber, it no longer matters, and "m" is the right thing. That said, the very same memory clobber may be what makes this whole approach a loss, if it causes gcc to do tons of reloads or other random things. That memory clobber wasn't an issue for the whole __preempt_count_dec_and_test() thing, because there we needed to keep anything before the decrement contained anyway. For other cases? Who knows.. A lot of the "change and test atomically" things have the same containment need, so it might not be a problem. > I might have to add the clobber to the macro arguments so we can do > version without "memory" clobber, although bitops is inconsistent with > that as well, __test_and_clear_bit() doesn't have a memory clobber but > __test_and_change_bit() does. You do need the memory clobber. The "asm goto" version can not have outputs, so "=m" and "+m" are both no-go, and so the only thing left is that memory clobber, as far as I can see.. The bitops didn't use to need it, because they had that "+/=m" that already tells gcc that the target is changed. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html