All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: qla1280: Replace arithmetic addition by bitwise OR
@ 2023-02-07 11:54 Deepak R Varma
  2023-02-11 23:25 ` Bart Van Assche
  0 siblings, 1 reply; 6+ messages in thread
From: Deepak R Varma @ 2023-02-07 11:54 UTC (permalink / raw)
  To: Michael Reed, James E.J. Bottomley, Martin K. Petersen,
	linux-scsi, linux-kernel
  Cc: Saurabh Singh Sengar, Praveen Kumar, Deepak R Varma

When adding two bit-field mask values, an OR operation offers higher
performance over an arithmetic operation. So, convert such addition to
an OR based expression.
Issue identified using orplus.cocci semantic patch script.

Signed-off-by: Deepak R Varma <drv@mailo.com>
---
 drivers/scsi/qla1280.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 1e7f4d138e06..d806beb4ad1c 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -3709,7 +3709,7 @@ qla1280_error_entry(struct scsi_qla_host *ha, struct response *pkt,
 		ha->outstanding_cmds[handle] = NULL;
 
 		/* Bad payload or header */
-		if (pkt->entry_status & (BIT_3 + BIT_2)) {
+		if (pkt->entry_status & (BIT_3 | BIT_2)) {
 			/* Bad payload or header, set error status. */
 			/* CMD_RESULT(sp->cmd) = CS_BAD_PAYLOAD; */
 			CMD_RESULT(sp->cmd) = DID_ERROR << 16;
-- 
2.34.1




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: qla1280: Replace arithmetic addition by bitwise OR
  2023-02-07 11:54 [PATCH] scsi: qla1280: Replace arithmetic addition by bitwise OR Deepak R Varma
@ 2023-02-11 23:25 ` Bart Van Assche
  2023-02-12 15:08   ` Deepak R Varma
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2023-02-11 23:25 UTC (permalink / raw)
  To: Deepak R Varma, Michael Reed, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-kernel
  Cc: Saurabh Singh Sengar, Praveen Kumar

On 2/7/23 03:54, Deepak R Varma wrote:
> When adding two bit-field mask values, an OR operation offers higher
> performance over an arithmetic operation. So, convert such addition to
> an OR based expression.

Where is the evidence that supports this claim? On the following page I 
read that there is no performance difference when using a modern CPU: 
https://cs.stackexchange.com/questions/75811/why-is-addition-as-fast-as-bit-wise-operations-in-modern-processors

> Issue identified using orplus.cocci semantic patch script.

Where is that script located? Can it be deleted such that submission of 
patches similar to this patch stops?

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: qla1280: Replace arithmetic addition by bitwise OR
  2023-02-11 23:25 ` Bart Van Assche
@ 2023-02-12 15:08   ` Deepak R Varma
  2023-02-12 15:11     ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Deepak R Varma @ 2023-02-12 15:08 UTC (permalink / raw)
  To: Bart Van Assche, Julia Lawall
  Cc: Michael Reed, James E.J. Bottomley, Martin K. Petersen,
	linux-scsi, linux-kernel, Saurabh Singh Sengar, Praveen Kumar,
	Deepak R Varma

On Sat, Feb 11, 2023 at 03:25:03PM -0800, Bart Van Assche wrote:
> On 2/7/23 03:54, Deepak R Varma wrote:
> > When adding two bit-field mask values, an OR operation offers higher
> > performance over an arithmetic operation. So, convert such addition to
> > an OR based expression.
> 
> Where is the evidence that supports this claim? On the following page I read
> that there is no performance difference when using a modern CPU: https://cs.stackexchange.com/questions/75811/why-is-addition-as-fast-as-bit-wise-operations-in-modern-processors
> 

Hello Bart,
You are correct. Modern CPU designs have improved addition and the performance
is at par with the bitwise operation. The document I had read earlier mentioned
a performance improvement for old CPUs and microprocessors, which today is not
the case. Thank you for sharing the link.

> > Issue identified using orplus.cocci semantic patch script.
> 
> Where is that script located? Can it be deleted such that submission of
> patches similar to this patch stops?

I have added Julia to this email to understand how to best use this semantic
patch. I already discussed with her on improving the Semantic patch such that it
doesn't suggest making change when constants are involved.

Thank you,
./drv

> 
> Thanks,
> 
> Bart.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: qla1280: Replace arithmetic addition by bitwise OR
  2023-02-12 15:08   ` Deepak R Varma
@ 2023-02-12 15:11     ` Julia Lawall
  2023-02-12 15:25       ` Deepak R Varma
  0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2023-02-12 15:11 UTC (permalink / raw)
  To: Deepak R Varma
  Cc: Bart Van Assche, Michael Reed, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-kernel,
	Saurabh Singh Sengar, Praveen Kumar



On Sun, 12 Feb 2023, Deepak R Varma wrote:

> On Sat, Feb 11, 2023 at 03:25:03PM -0800, Bart Van Assche wrote:
> > On 2/7/23 03:54, Deepak R Varma wrote:
> > > When adding two bit-field mask values, an OR operation offers higher
> > > performance over an arithmetic operation. So, convert such addition to
> > > an OR based expression.
> >
> > Where is the evidence that supports this claim? On the following page I read
> > that there is no performance difference when using a modern CPU: https://cs.stackexchange.com/questions/75811/why-is-addition-as-fast-as-bit-wise-operations-in-modern-processors
> >
>
> Hello Bart,
> You are correct. Modern CPU designs have improved addition and the performance
> is at par with the bitwise operation. The document I had read earlier mentioned
> a performance improvement for old CPUs and microprocessors, which today is not
> the case. Thank you for sharing the link.
>
> > > Issue identified using orplus.cocci semantic patch script.
> >
> > Where is that script located? Can it be deleted such that submission of
> > patches similar to this patch stops?
>
> I have added Julia to this email to understand how to best use this semantic
> patch. I already discussed with her on improving the Semantic patch such that it
> doesn't suggest making change when constants are involved.

FWIW, the semantic patch was never motivated by efficiency, but rather
with the goal of making the code more understandable.

julia

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: qla1280: Replace arithmetic addition by bitwise OR
  2023-02-12 15:11     ` Julia Lawall
@ 2023-02-12 15:25       ` Deepak R Varma
  2023-02-12 16:15         ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Deepak R Varma @ 2023-02-12 15:25 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Bart Van Assche, Michael Reed, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-kernel,
	Saurabh Singh Sengar, Praveen Kumar, Deepak R Varma

On Sun, Feb 12, 2023 at 04:11:58PM +0100, Julia Lawall wrote:
> 
> 
> On Sun, 12 Feb 2023, Deepak R Varma wrote:
> 
> > On Sat, Feb 11, 2023 at 03:25:03PM -0800, Bart Van Assche wrote:
> > > On 2/7/23 03:54, Deepak R Varma wrote:
> > > > When adding two bit-field mask values, an OR operation offers higher
> > > > performance over an arithmetic operation. So, convert such addition to
> > > > an OR based expression.
> > >
> > > Where is the evidence that supports this claim? On the following page I read
> > > that there is no performance difference when using a modern CPU: https://cs.stackexchange.com/questions/75811/why-is-addition-as-fast-as-bit-wise-operations-in-modern-processors
> > >
> >
> > Hello Bart,
> > You are correct. Modern CPU designs have improved addition and the performance
> > is at par with the bitwise operation. The document I had read earlier mentioned
> > a performance improvement for old CPUs and microprocessors, which today is not
> > the case. Thank you for sharing the link.
> >
> > > > Issue identified using orplus.cocci semantic patch script.
> > >
> > > Where is that script located? Can it be deleted such that submission of
> > > patches similar to this patch stops?
> >
> > I have added Julia to this email to understand how to best use this semantic
> > patch. I already discussed with her on improving the Semantic patch such that it
> > doesn't suggest making change when constants are involved.
> 
> FWIW, the semantic patch was never motivated by efficiency, but rather
> with the goal of making the code more understandable.

I think my interpretation of the patch log for [1] was not accurate. The line
"Running time is divided by 3 ..." made me believe OR'ing would replace "F+A+R"
instructions by a single operation. My bad.

[1] https://lore.kernel.org/all/alpine.DEB.2.20.1711130649370.2483@hadrien/

> 
> julia



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] scsi: qla1280: Replace arithmetic addition by bitwise OR
  2023-02-12 15:25       ` Deepak R Varma
@ 2023-02-12 16:15         ` Julia Lawall
  0 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2023-02-12 16:15 UTC (permalink / raw)
  To: Deepak R Varma
  Cc: Julia Lawall, Bart Van Assche, Michael Reed,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	linux-kernel, Saurabh Singh Sengar, Praveen Kumar



On Sun, 12 Feb 2023, Deepak R Varma wrote:

> On Sun, Feb 12, 2023 at 04:11:58PM +0100, Julia Lawall wrote:
> >
> >
> > On Sun, 12 Feb 2023, Deepak R Varma wrote:
> >
> > > On Sat, Feb 11, 2023 at 03:25:03PM -0800, Bart Van Assche wrote:
> > > > On 2/7/23 03:54, Deepak R Varma wrote:
> > > > > When adding two bit-field mask values, an OR operation offers higher
> > > > > performance over an arithmetic operation. So, convert such addition to
> > > > > an OR based expression.
> > > >
> > > > Where is the evidence that supports this claim? On the following page I read
> > > > that there is no performance difference when using a modern CPU: https://cs.stackexchange.com/questions/75811/why-is-addition-as-fast-as-bit-wise-operations-in-modern-processors
> > > >
> > >
> > > Hello Bart,
> > > You are correct. Modern CPU designs have improved addition and the performance
> > > is at par with the bitwise operation. The document I had read earlier mentioned
> > > a performance improvement for old CPUs and microprocessors, which today is not
> > > the case. Thank you for sharing the link.
> > >
> > > > > Issue identified using orplus.cocci semantic patch script.
> > > >
> > > > Where is that script located? Can it be deleted such that submission of
> > > > patches similar to this patch stops?
> > >
> > > I have added Julia to this email to understand how to best use this semantic
> > > patch. I already discussed with her on improving the Semantic patch such that it
> > > doesn't suggest making change when constants are involved.
> >
> > FWIW, the semantic patch was never motivated by efficiency, but rather
> > with the goal of making the code more understandable.
>
> I think my interpretation of the patch log for [1] was not accurate. The line
> "Running time is divided by 3 ..." made me believe OR'ing would replace "F+A+R"
> instructions by a single operation. My bad.

Ah, interesting.  I have no idea any more the running time of what.

julia


>
> [1] https://lore.kernel.org/all/alpine.DEB.2.20.1711130649370.2483@hadrien/
>
> >
> > julia
>
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-02-12 16:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07 11:54 [PATCH] scsi: qla1280: Replace arithmetic addition by bitwise OR Deepak R Varma
2023-02-11 23:25 ` Bart Van Assche
2023-02-12 15:08   ` Deepak R Varma
2023-02-12 15:11     ` Julia Lawall
2023-02-12 15:25       ` Deepak R Varma
2023-02-12 16:15         ` Julia Lawall

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.