Re: [PATCH RFC 0/3] Static calls

From: Josh Poimboeuf
Date: Fri Nov 09 2018 - 09:45:08 EST


On Fri, Nov 09, 2018 at 08:28:11AM +0100, Ingo Molnar wrote:
> > - I'm not sure about the objtool approach. Objtool is (currently)
> > x86-64 only, which means we have to use the "unoptimized" version
> > everywhere else. I may experiment with a GCC plugin instead.
>
> I'd prefer the objtool approach. It's a pretty reliable first-principles
> approach while GCC plugin would have to be replicated for Clang and any
> other compilers, etc.

The benefit of a plugin is that we'd only need two of them: GCC and
Clang. And presumably, they'd share a lot of code.

The prospect of porting objtool to all architectures is going to be much
more of a daunting task (though we are at least already considering it
for some arches).

> > - Does this feature have much value without retpolines? If not, should
> > we make it depend on retpolines somehow?
>
> Paravirt patching, as you mention in your later reply?
>
> > - Find some actual users of the interfaces (tracepoints? crypto?)
>
> I'd be very happy with a demonstrated paravirt optimization already -
> i.e. seeing the before/after effect on the vmlinux with an x86 distro
> config.
>
> All major Linux distributions enable CONFIG_PARAVIRT=y and
> CONFIG_PARAVIRT_XXL=y on x86 at the moment, so optimizing it away as much
> as possible in the 99.999% cases where it's not used is a primary
> concern.

For paravirt, I was thinking of it as more of a cleanup than an
optimization. The paravirt patching code already replaces indirect
branches with direct ones -- see paravirt_patch_default().

Though it *would* reduce the instruction footprint a bit, as the 7-byte
indirect calls (later patched to 5-byte direct + 2-byte nop) would
instead be 5-byte direct calls to begin with.

> All other usecases are bonus, but it would certainly be interesting to
> investigate the impact of using these APIs for tracing: that too is a
> feature enabled everywhere but utilized only by a small fraction of Linux
> users - so literally every single cycle or instruction saved or hot-path
> shortened is a major win.

With retpolines, and with tracepoints enabled, it's definitely a major
win. Steve measured an 8.9% general slowdown on hackbench caused by
retpolines.

But with tracepoints disabled, I believe static jumps are used, which
already minimizes the impact on hot paths.

--
Josh