[PATCH] staging: fsl-mc/dpio: Fix incorrect comparison

Ruxandra Ioana Radulescu ruxandra.radulescu at nxp.com
Thu Sep 28 13:23:56 UTC 2017


> -----Original Message-----
> From: gregkh at linuxfoundation.org [mailto:gregkh at linuxfoundation.org]
> Sent: Thursday, September 28, 2017 4:18 PM
> To: Ruxandra Ioana Radulescu <ruxandra.radulescu at nxp.com>
> Cc: Dan Carpenter <dan.carpenter at oracle.com>;
> devel at driverdev.osuosl.org; arnd at arndb.de; stuyoder at gmail.com; Roy
> Pledge <roy.pledge at nxp.com>; linux-kernel at vger.kernel.org;
> agraf at suse.de; Bogdan Purcareata <bogdan.purcareata at nxp.com>;
> Laurentiu Tudor <laurentiu.tudor at nxp.com>
> Subject: Re: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison
> 
> On Thu, Sep 28, 2017 at 01:07:48PM +0000, Ruxandra Ioana Radulescu wrote:
> > > -----Original Message-----
> > > From: Dan Carpenter [mailto:dan.carpenter at oracle.com]
> > > Sent: Thursday, September 28, 2017 3:49 PM
> > > To: Ruxandra Ioana Radulescu <ruxandra.radulescu at nxp.com>
> > > Cc: gregkh at linuxfoundation.org; devel at driverdev.osuosl.org;
> > > arnd at arndb.de; stuyoder at gmail.com; Roy Pledge
> <roy.pledge at nxp.com>;
> > > linux-kernel at vger.kernel.org; agraf at suse.de; Bogdan Purcareata
> > > <bogdan.purcareata at nxp.com>; Laurentiu Tudor
> > > <laurentiu.tudor at nxp.com>
> > > Subject: Re: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison
> > >
> > > On Wed, Sep 27, 2017 at 12:57:28PM -0500, Ioana Radulescu wrote:
> > > > diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > > b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > > > index f809682..26922fc 100644
> > > > --- a/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > > > +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-service.c
> > > > @@ -76,7 +76,7 @@ static inline struct dpaa2_io
> > > *service_select_by_cpu(struct dpaa2_io *d,
> > > >  	if (d)
> > > >  		return d;
> > > >
> > > > -	if (unlikely(cpu >= num_possible_cpus()))
> > > > +	if (unlikely(cpu >= (int)num_possible_cpus()))
> > >
> > >
> > > Drivers shouldn't use likely/unlikley.
> >
> > I was under the impression it's ok to use them on hotpath
> > (and while not entirely obvious, this function is called on
> > other drivers' hotpath).
> 
> Only use it if you can measure the difference.  If you can not, then do
> not use it as the compiler and the CPU will guess it better than you
> will.
> 
> This has been proven many times, something like 80% of our
> likely/unlikely usage in the kernel is wrong because of this, see the
> work from Andi Kleen many years ago in this area.
> 
> So please remove it.  Unless you can prove it matters, and if so,
> document that.
 
Greg, thanks for the explanation. Will remove it in v2.

Ioana


More information about the devel mailing list