Re: [PATCH v2 0/4] Static calls
From: Edward Cree
Date: Wed Dec 12 2018 - 16:36:31 EST
On 12/12/18 21:15, Nadav Amit wrote:
>> On Dec 12, 2018, at 10:33 AM, Edward Cree <ecree@xxxxxxxxxxxxxx> wrote:
>>
>> AIUI the outline version uses a tail-call (i.e. jmpq *target) rather than an
>> additional call and ret. So I wouldn't expect it to be too expensive.
>> More to the point, it seems like it's easier to get right than the inline
>> version, and if we get the inline version working later we can introduce it
>> without any API change, much as Josh's existing patches have both versions
>> behind a Kconfig switch.
> I see. For my outlined blocks I used the opposite approach - a call followed
> by jmp
That's what Josh did too. I.e. caller calls the trampoline, which jmps to the
Âcallee; later it rets, taking it back to the caller. Perhaps I wasn't clear.
The point is that there's still only one call and one ret.
>> I was working on the assumption that it would be opt-in, wrapping a macro
>> around indirect calls that are known to have a fairly small number of hot
>> targets. There are plenty of indirect calls in the kernel that are only
>> called once in a blue moon, e.g. in control-plane operations like ethtool;
>> we don't really need to bulk up .text with trampolines for all of them.
> On the other hand, Iâm not sure the static_call interface is so intuitive.
> And extending it into âdynamic_callâ might be even worse. As I initially
> used an opt-in approach, I can tell you that it was very exhausting.
Well, if it's done with a gcc plugin after all, then it wouldn't be too hard
Âto make it opt-out.
One advantage of the explicit opt-in dynamic_call, though, which can be seen
Âin my patch is that multiple call sites can share the same learning-state,
Âif they're expected to call the same set of functions. An opt-out approach
Âwould automatically give each indirect call statement its own individual BTB.
Either way, I think the question is orthogonal to what the trampolines
Âthemselves look like (and even to the inline vs outline question).
-Ed