Re: [PATCH] x86: Align jump targets to 1 byte boundaries

From: Josh Triplett
Date: Sat Apr 11 2015 - 10:29:03 EST


On Fri, Apr 10, 2015 at 07:10:08AM -0700, Paul E. McKenney wrote:
> On Fri, Apr 10, 2015 at 02:08:46PM +0200, Ingo Molnar wrote:
> > * Ingo Molnar <mingo@xxxxxxxxxx> wrote:
[...]
> > Btw., totally off topic, the following NOP caught my attention:
> >
> > > 5a: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
> >
> > That's a dead NOP that boats the function a bit, added for the 16 byte
> > alignment of one of the jump targets.
> >
> > I realize that x86 CPU manufacturers recommend 16-byte jump target
> > alignments (it's in the Intel optimization manual), but the cost of
> > that is very significant:
> >
> > text data bss dec filename
> > 12566391 1617840 1089536 15273767 vmlinux.align.16-byte
> > 12224951 1617840 1089536 14932327 vmlinux.align.1-byte
> >
> > By using 1 byte jump target alignment (i.e. no alignment at all) we
> > get an almost 3% reduction in kernel size (!) - and a probably similar
> > reduction in I$ footprint.
> >
> > So I'm wondering, is the 16 byte jump target optimization suggestion
> > really worth this price? The patch below boots fine and I've not
> > measured any noticeable slowdown, but I've not tried hard.
>
> Good point, adding Josh Triplett on CC. I suspect that he might be
> interested. ;-)

Quite interested, yes. Even if there *are* benchmarks to support
keeping the optimization (which wouldn't surprise me), it'd be nice to
have a Kconfig option to enable the jump-target optimization. (With 'y'
meaning "pad jump targets to 16 bytes", so that allnoconfig and
tinyconfig automatically don't.)

- Josh Triplett
--
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/