public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* 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

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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox