Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753468AbdI1NSD (ORCPT ); Thu, 28 Sep 2017 09:18:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48064 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753292AbdI1NSB (ORCPT ); Thu, 28 Sep 2017 09:18:01 -0400 Date: Thu, 28 Sep 2017 15:17:57 +0200 From: "gregkh@linuxfoundation.org" To: Ruxandra Ioana Radulescu Cc: Dan Carpenter , "devel@driverdev.osuosl.org" , "arnd@arndb.de" , "stuyoder@gmail.com" , Roy Pledge , "linux-kernel@vger.kernel.org" , "agraf@suse.de" , Bogdan Purcareata , Laurentiu Tudor Subject: Re: [PATCH] staging: fsl-mc/dpio: Fix incorrect comparison Message-ID: <20170928131757.GA23657@kroah.com> References: <20170927175728.3307-1-ruxandra.radulescu@nxp.com> <20170928124836.kdqjowqibab53hf5@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1854 Lines: 47 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 > > Cc: gregkh@linuxfoundation.org; devel@driverdev.osuosl.org; > > arnd@arndb.de; stuyoder@gmail.com; Roy Pledge ; > > linux-kernel@vger.kernel.org; agraf@suse.de; Bogdan Purcareata > > ; Laurentiu Tudor > > > > 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