All of lore.kernel.org
 help / color / mirror / Atom feed
From: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
To: Ruxandra Ioana Radulescu <ruxandra.radulescu@nxp.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"stuyoder@gmail.com" <stuyoder@gmail.com>,
	Roy Pledge <roy.pledge@nxp.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"agraf@suse.de" <agraf@suse.de>,
	Bogdan Purcareata <bogdan.purcareata@nxp.com>,
	Laurentiu Tudor <laurentiu.tudor@nxp.com>
Subject: Re: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison
Date: Thu, 28 Sep 2017 15:17:57 +0200	[thread overview]
Message-ID: <20170928131757.GA23657@kroah.com> (raw)
In-Reply-To: <VI1PR0402MB28470F19FE7A585E7F1B184394790@VI1PR0402MB2847.eurprd04.prod.outlook.com>

On Thu, Sep 28, 2017 at 01:07:48PM +0000, Ruxandra Ioana Radulescu wrote:
> > -----Original Message-----
> > From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> > Sent: Thursday, September 28, 2017 3:49 PM
> > To: Ruxandra Ioana Radulescu <ruxandra.radulescu@nxp.com>
> > Cc: gregkh@linuxfoundation.org; devel@driverdev.osuosl.org;
> > arnd@arndb.de; stuyoder@gmail.com; Roy Pledge <roy.pledge@nxp.com>;
> > linux-kernel@vger.kernel.org; agraf@suse.de; Bogdan Purcareata
> > <bogdan.purcareata@nxp.com>; Laurentiu Tudor
> > <laurentiu.tudor@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.

thanks,

greg k-h

  reply	other threads:[~2017-09-28 13:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-27 17:57 [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison Ioana Radulescu
2017-09-28 12:48 ` Dan Carpenter
2017-09-28 12:53   ` Dan Carpenter
2017-09-28 13:07   ` Ruxandra Ioana Radulescu
2017-09-28 13:17     ` gregkh [this message]
2017-09-28 13:23       ` Ruxandra Ioana Radulescu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170928131757.GA23657@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=agraf@suse.de \
    --cc=arnd@arndb.de \
    --cc=bogdan.purcareata@nxp.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=laurentiu.tudor@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roy.pledge@nxp.com \
    --cc=ruxandra.radulescu@nxp.com \
    --cc=stuyoder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.