public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: "Xu, Even" <even.xu@intel.com>
Cc: lkp <lkp@intel.com>,
	"oe-kbuild-all@lists.linux.dev" <oe-kbuild-all@lists.linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Jiri Kosina <jikos@kernel.org>,
	"Sun, Xinpeng" <xinpeng.sun@intel.com>,
	"Srinivas Pandruvada" <srinivas.pandruvada@linux.intel.com>,
	Mark Pearson <mpearson-lenovo@squebb.ca>
Subject: Re: drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c:298:38: sparse: sparse: dubious: !x | !y
Date: Wed, 5 Feb 2025 21:56:50 +0000	[thread overview]
Message-ID: <20250205215650.1a93dc58@pumpkin> (raw)
In-Reply-To: <IA1PR11MB6098ECA558A36C0EAA1F21FCF4F72@IA1PR11MB6098.namprd11.prod.outlook.com>

On Wed, 5 Feb 2025 02:56:05 +0000
"Xu, Even" <even.xu@intel.com> wrote:

> > -----Original Message-----
> > From: David Laight <david.laight.linux@gmail.com>
> > Sent: Thursday, January 30, 2025 6:22 AM
> > To: lkp <lkp@intel.com>
> > Cc: Xu, Even <even.xu@intel.com>; oe-kbuild-all@lists.linux.dev; linux-
> > kernel@vger.kernel.org; Jiri Kosina <jikos@kernel.org>; Sun, Xinpeng
> > <xinpeng.sun@intel.com>; Srinivas Pandruvada
> > <srinivas.pandruvada@linux.intel.com>; Mark Pearson <mpearson-  
> > lenovo@squebb.ca>  
> > Subject: Re: drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c:298:38: sparse:
> > sparse: dubious: !x | !y
> > 
> > On Wed, 29 Jan 2025 22:02:59 +0800
> > kernel test robot <lkp@intel.com> wrote:
> >   
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > head:   05dbaf8dd8bf537d4b4eb3115ab42a5fb40ff1f5
> > > commit: a688404b2e20f00cce6d0a2b888ef4ca9154e144 HID: intel-thc-hid:  
> > intel-thc: Add THC DMA interfaces  
> > > date:   3 weeks ago
> > > config: x86_64-allyesconfig
> > > (https://download.01.org/0day-ci/archive/20250129/202501292144.eFDq4ov
> > > r-lkp@intel.com/config)
> > > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1
> > > build):
> > > (https://download.01.org/0day-ci/archive/20250129/202501292144.eFDq4ov
> > > r-lkp@intel.com/reproduce)
> > >
> > > If you fix the issue in a separate patch/commit (i.e. not just a new
> > > version of the same patch/commit), kindly add following tags
> > > | Reported-by: kernel test robot <lkp@intel.com>
> > > | Closes:
> > > | https://lore.kernel.org/oe-kbuild-all/202501292144.eFDq4ovr-lkp@inte
> > > | l.com/
> > >
> > > sparse warnings: (new ones prefixed by >>)  
> > > >> drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c:298:38: sparse:
> > > >> sparse: dubious: !x | !y  
> > >    drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c: note: in included file  
> > (through include/linux/mmzone.h, include/linux/gfp.h, include/linux/mm.h, ...):  
> > >    include/linux/page-flags.h:237:46: sparse: sparse: self-comparison always  
> > evaluates to false  
> > >    include/linux/page-flags.h:237:46: sparse: sparse: self-comparison
> > > always evaluates to false
> > >
> > > vim +298 drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c  
> > ...  
> > >    297		for (i = 0; i < config->prd_tbl_num; i++) {  
> > >  > 298			if (!config->sgls[i] | !config->sgls_nent[i])  
> > >    299				continue;  
> > ...
> > 
> > If zeros are unlikely the bit-wise 'or' is pretty likely to generate better code than a
> > logical 'or'.
> > 
> > 	David  
> 
> Good suggestion!
> So the code can be optimized to:
> 	for (i = 0; i < config->prd_tbl_num; i++) {
> 	         if (config->sgls[i] && config->sgls_nent[i]) {
>                                     ......
>                        }

That just adds a level of indentation to the source.
It'll generate much the same code as !x || !y.
Both will generate two conditional branches.

It almost certainly makes in immeasurable difference here, but !x | !y
can be generated using (on x86) the 'sete' instruction to get a 0/1 from
the x == 0 compare (that sets the flags), and then doing an 'or' and a
single jump.

	David

> 	}
> 
> Will create a patch for this.
> 
> Best Regards,
> Even Xu
> 
> 


  reply	other threads:[~2025-02-05 21:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-29 14:02 drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c:298:38: sparse: sparse: dubious: !x | !y kernel test robot
2025-01-29 22:21 ` David Laight
2025-02-05  2:56   ` Xu, Even
2025-02-05 21:56     ` David Laight [this message]
2025-02-06  2:50       ` Xu, Even
2025-02-06  9:04         ` David Laight
2025-02-07  6:11           ` Xu, Even

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=20250205215650.1a93dc58@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=even.xu@intel.com \
    --cc=jikos@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=mpearson-lenovo@squebb.ca \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=xinpeng.sun@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox