On Fri, May 01, 2015 at 06:16:54PM +0200, Peter Zijlstra wrote: > On Fri, May 01, 2015 at 09:03:32AM -0700, Linus Torvalds wrote: > > On Fri, May 1, 2015 at 8:16 AM, Peter Zijlstra <pet...@infradead.org> wrote: > > > > > > Since test_bit() doesn't actually have any output variables, we can use > > > asm goto without having to add a memory clobber. This reduces the code > > > to something sensible: > > > > Yes, looks good, except if we have anything that actually wants to use > > the value rather than branch on it. But a quick grep seems to show > > that the vast majority of them are all about just directly testing the > > result. > > > > It worries me a bit that gcc now cannot pick the likely branch any > > more. It will always branch out for the bit being set. So code like > > this: > > > > net/core/dev.c: if > > (likely(!test_bit(__QDISC_STATE_DEACTIVATED, &q->state))) > > > > wouldn't work, but almost all of those seem to be the constant case > > that doesn't get to this anyway. > > Ah yes, that's another thing we've previously discussed with the GCC > people (IIRC). The GCC manual states you can use hot and cold attributes > on the labels (although when we tested that it didn't actually work, it > might now). But that's no good if the hint is one (or more) layer up > from the asm goto. > > If would indeed be very good if the likely/unlikely thing would work as > expected.
Ah, I see what you meant. Yes we're stuck with the 'jc', the compiler cannot flip that into a jnc. The best it can do is add unconditional jumps to re-arrange the blocks, and that's somewhat ugly indeed, although better than nothing at all. And from experiments back when we did the static_branch stuff that all didn't work at all. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/