[dpdk-dev] [PATCH v1 1/3] port: add mp/mc ring ports

Dumitrescu, Cristian cristian.dumitrescu at intel.com
Wed Sep 23 15:07:01 CEST 2015



> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> Sent: Tuesday, September 22, 2015 5:24 PM
> To: Dumitrescu, Cristian
> Cc: dev at dpdk.org; Stephen Hemminger; Azarewicz, PiotrX T
> Subject: Re: [dpdk-dev] [PATCH v1 1/3] port: add mp/mc ring ports
> 
> 2015-09-22 11:34, Dumitrescu, Cristian:
> >
> > > -----Original Message-----
> > > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Stephen
> > > Hemminger
> > > Sent: Tuesday, September 22, 2015 1:36 AM
> > > To: Azarewicz, PiotrX T
> > > Cc: dev at dpdk.org
> > > Subject: Re: [dpdk-dev] [PATCH v1 1/3] port: add mp/mc ring ports
> > >
> > > On Tue, 15 Sep 2015 15:06:33 +0200
> > > Piotr Azarewicz <piotrx.t.azarewicz at intel.com> wrote:
> > >
> > > > +static inline void
> > > > +send_burst_mp(struct rte_port_ring_writer *p)
> > > > +{
> > >
> > > compiler will inline static functions anyway. No need to add inline qualifier
> >
> > Hi Stephen,
> >
> > Using 'static inline' seems to be the standard practice in DPDK and a good
> practice as well.
> 
> Why do you think it is a good practice?
> Forced inlining can be a random optimization having negative effects.
> 

What I meant is this: when users want to make sure their code gets inlined by the compiler, it is better to explicitly state this by using the mechanisms provided by the C compiler (C keyword "inline" and compiler pragmas like "always inline") rather than hope that compiler is going to do this anyway. I have been burned in the past by compilers not inlining code even when explicitly stated, so I am a quite sceptical about compilers doing it proactively.

Your point is slightly different: why use code inlining at all? IMHO this discussion is outside the scope of this patch and should be conducted as a separate debate. Please feel free to start it as a separate thread if you deem necessary. As said, there are already 1700 instances of "static inline" in DPDK, as well as lots of "always inline".

In the context of this debate (outside the scope of this patch), my quick input is:  compilers are typically good to optimize code at the function level rather than cross-functions, so having more code in the same function allows the compiler to do a better job at code optimization. I am not a compiler expert, so my views could simply be biased by my past experience.

> > DPDK> grep 'static inline' `find -name '*.[hc]'` | wc -l
> > 1700



More information about the dev mailing list