* Use of Indirect function calls
@ 2018-03-07 3:35 Rao Shoaib
2018-03-07 4:43 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Rao Shoaib @ 2018-03-07 3:35 UTC (permalink / raw)
To: netdev, David Miller, Eric Dumazet
I am working on a change which introduces a couple of indirect function
calls in the fast path. I used indirect function calls instead of
"if/else" as it keeps the code cleaner and more readable and provides
for extensibility.
I do not expect any measurable overhead as modern CPU's use pre-fetching
and multiple parallel execution engines. Indirect jump prediction has
gotten very good too. Assembly shows that the difference is an
instruction to get the table address followed by a call to *callq
instead of callq. I could not find official Intel numbers[1] but third
party numbers suggest that *callq may have an over head of 1 clock
cycle. Over head of accessing the table address is similar to reading a
variable or testing a flag.
Will a patch that introduces indirect function calls be rejected just
because it uses indirect function calls in the fast path or is the
use/impact evaluated on a case by case basis ? I do see usage of
indirect function calls in TCP fast path and Ethernet drivers so it
can't be that bad.
Regards,
Shoaib
[1] I believe this is because the instruction is broken down into
multiple uops and due to perfecting and parallel execution the latency
is hard to measure.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Use of Indirect function calls
2018-03-07 3:35 Use of Indirect function calls Rao Shoaib
@ 2018-03-07 4:43 ` David Miller
2018-03-07 5:53 ` Rao Shoaib
0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2018-03-07 4:43 UTC (permalink / raw)
To: rao.shoaib; +Cc: netdev, eric.dumazet
From: Rao Shoaib <rao.shoaib@oracle.com>
Date: Tue, 6 Mar 2018 19:35:46 -0800
> I do not expect any measurable overhead as modern CPU's use
> pre-fetching and multiple parallel execution engines.
Please see Spectre and retpolines, all of this parallel execution and
prefetching is essentially disabled to address those vulnerabilities
and side-channel exploits.
Indirect calls are terrible and we are now looking at ways in which
we can remove them from as many parts of the networking as possible.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Use of Indirect function calls
2018-03-07 4:43 ` David Miller
@ 2018-03-07 5:53 ` Rao Shoaib
2018-03-07 6:32 ` Eric Dumazet
2018-03-07 15:06 ` David Miller
0 siblings, 2 replies; 6+ messages in thread
From: Rao Shoaib @ 2018-03-07 5:53 UTC (permalink / raw)
To: David Miller; +Cc: netdev, eric.dumazet
David,
Thanks a lot for your prompt response. Do you have a specific solution
in mind or will the calls be replaced with simple checks ?
Also while I have your attention can I ask your opinion about breaking
up some TCP functions, mostly control functions into smaller units so
that if a little different behavior is desired it can be achieved and
common code could still be shared. Of course you can not say much
without looking at the code but will you even entertain such a change ?
Regards,
Rao.
On 03/06/2018 08:43 PM, David Miller wrote:
> From: Rao Shoaib <rao.shoaib@oracle.com>
> Date: Tue, 6 Mar 2018 19:35:46 -0800
>
>> I do not expect any measurable overhead as modern CPU's use
>> pre-fetching and multiple parallel execution engines.
> Please see Spectre and retpolines, all of this parallel execution and
> prefetching is essentially disabled to address those vulnerabilities
> and side-channel exploits.
>
> Indirect calls are terrible and we are now looking at ways in which
> we can remove them from as many parts of the networking as possible.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Use of Indirect function calls
2018-03-07 5:53 ` Rao Shoaib
@ 2018-03-07 6:32 ` Eric Dumazet
2018-03-07 7:23 ` Rao Shoaib
2018-03-07 15:06 ` David Miller
1 sibling, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2018-03-07 6:32 UTC (permalink / raw)
To: Rao Shoaib, David Miller; +Cc: netdev
On Tue, 2018-03-06 at 21:53 -0800, Rao Shoaib wrote:
> David,
>
> Thanks a lot for your prompt response. Do you have a specific
> solution
> in mind or will the calls be replaced with simple checks ?
There is upcoming work for that, but not specific to TCP stack.
>
> Also while I have your attention can I ask your opinion about
> breaking
> up some TCP functions, mostly control functions into smaller units
> so
> that if a little different behavior is desired it can be achieved
> and
> common code could still be shared. Of course you can not say much
> without looking at the code but will you even entertain such a change
> ?
I am sorry, but I would prefer no code refactoring unless you fix a
serious bug, or prepare for something really new (and having noticeable
impact)
We have to maintain stable trees, and such code churns are adding
maintenance hassles.
Of course, you can submit patches, but be warned that you can not
expect us spending hours reviewing patches that might bring serious
regressions.
I suggest you start with small patches first.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Use of Indirect function calls
2018-03-07 6:32 ` Eric Dumazet
@ 2018-03-07 7:23 ` Rao Shoaib
0 siblings, 0 replies; 6+ messages in thread
From: Rao Shoaib @ 2018-03-07 7:23 UTC (permalink / raw)
To: Eric Dumazet, David Miller; +Cc: netdev
On 03/06/2018 10:32 PM, Eric Dumazet wrote:
> On Tue, 2018-03-06 at 21:53 -0800, Rao Shoaib wrote:
>> David,
>>
>> Thanks a lot for your prompt response. Do you have a specific
>> solution
>> in mind or will the calls be replaced with simple checks ?
> There is upcoming work for that, but not specific to TCP stack.
>
>> Also while I have your attention can I ask your opinion about
>> breaking
>> up some TCP functions, mostly control functions into smaller units
>> so
>> that if a little different behavior is desired it can be achieved
>> and
>> common code could still be shared. Of course you can not say much
>> without looking at the code but will you even entertain such a change
>> ?
> I am sorry, but I would prefer no code refactoring unless you fix a
> serious bug, or prepare for something really new (and having noticeable
> impact)
>
> We have to maintain stable trees, and such code churns are adding
> maintenance hassles.
>
> Of course, you can submit patches, but be warned that you can not
> expect us spending hours reviewing patches that might bring serious
> regressions.
>
> I suggest you start with small patches first.
>
Thanks a lot Eric, I absolutely understand your concerns. I asked the
question as I did not want to spend the time if you guys were not
willing to even entertain the idea. Thanks a lot for your flexibility.
The changes I am making are very simple and very unlikely to cause any
issues. You can always reject the patch as too big and I will work to
make it smaller.
Regards,
Shoaib
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Use of Indirect function calls
2018-03-07 5:53 ` Rao Shoaib
2018-03-07 6:32 ` Eric Dumazet
@ 2018-03-07 15:06 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2018-03-07 15:06 UTC (permalink / raw)
To: rao.shoaib; +Cc: netdev, eric.dumazet
From: Rao Shoaib <rao.shoaib@oracle.com>
Date: Tue, 6 Mar 2018 21:53:19 -0800
> Also while I have your attention can I ask your opinion about
> breaking up some TCP functions, mostly control functions into
> smaller units so that if a little different behavior is desired it
> can be achieved and common code could still be shared. Of course you
> can not say much without looking at the code but will you even
> entertain such a change ?
You answered your own question, I'd have to see what the change
looks like to make a determination.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-03-07 15:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-07 3:35 Use of Indirect function calls Rao Shoaib
2018-03-07 4:43 ` David Miller
2018-03-07 5:53 ` Rao Shoaib
2018-03-07 6:32 ` Eric Dumazet
2018-03-07 7:23 ` Rao Shoaib
2018-03-07 15:06 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.