linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] IB/mlx4: Use common error handling code in __mlx4_ib_create_flow()
@ 2017-10-26 16:12 SF Markus Elfring
  2017-10-27  0:33 ` Dennis Dalessandro
  2017-10-27 19:39 ` Leon Romanovsky
  0 siblings, 2 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-26 16:12 UTC (permalink / raw)
  To: linux-rdma, Dennis Dalessandro, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Sean Hefty, Yishai Hadas, Yuval Shaia
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Oct 2017 17:54:15 +0200

Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/mlx4/main.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index c636842c5be0..4a598c48ea1c 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1691,8 +1691,8 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
 				mdev, qp, default_table + default_flow,
 				mailbox->buf + size);
 		if (ret < 0) {
-			mlx4_free_cmd_mailbox(mdev->dev, mailbox);
-			return -EINVAL;
+			ret = -EINVAL;
+			goto free_mailbox;
 		}
 		size += ret;
 	}
@@ -1700,8 +1700,8 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
 		ret = parse_flow_attr(mdev->dev, qp->qp_num, ib_flow,
 				      mailbox->buf + size);
 		if (ret < 0) {
-			mlx4_free_cmd_mailbox(mdev->dev, mailbox);
-			return -EINVAL;
+			ret = -EINVAL;
+			goto free_mailbox;
 		}
 		ib_flow += ((union ib_flow_spec *) ib_flow)->size;
 		size += ret;
@@ -1726,7 +1726,7 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
 		pr_err("Device managed flow steering is disabled. Fail to register network rule.\n");
 	else if (ret)
 		pr_err("Invalid argument. Fail to register network rule.\n");
-
+free_mailbox:
 	mlx4_free_cmd_mailbox(mdev->dev, mailbox);
 	return ret;
 }
-- 
2.14.3

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

* Re: [PATCH] IB/mlx4: Use common error handling code in __mlx4_ib_create_flow()
  2017-10-26 16:12 [PATCH] IB/mlx4: Use common error handling code in __mlx4_ib_create_flow() SF Markus Elfring
@ 2017-10-27  0:33 ` Dennis Dalessandro
  2017-10-27  7:34   ` SF Markus Elfring
  2017-10-27 19:44   ` [PATCH] " Leon Romanovsky
  2017-10-27 19:39 ` Leon Romanovsky
  1 sibling, 2 replies; 12+ messages in thread
From: Dennis Dalessandro @ 2017-10-27  0:33 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma, Doug Ledford, Hal Rosenstock,
	Leon Romanovsky, Sean Hefty, Yishai Hadas, Yuval Shaia
  Cc: LKML, kernel-janitors

On 10/26/2017 12:12 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 26 Oct 2017 17:54:15 +0200
> 
> Add a jump target so that a bit of exception handling can be better reused
> at the end of this function.

I'm not sure this is that big of a win. I mean you aren't really making 
the code any smaller and it's not making it any easier to read really.

> This issue was detected by using the Coccinelle software.

Assuming there was no testing done for this?

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   drivers/infiniband/hw/mlx4/main.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index c636842c5be0..4a598c48ea1c 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -1691,8 +1691,8 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
>   				mdev, qp, default_table + default_flow,
>   				mailbox->buf + size);
>   		if (ret < 0) {
> -			mlx4_free_cmd_mailbox(mdev->dev, mailbox);
> -			return -EINVAL;
> +			ret = -EINVAL;
> +			goto free_mailbox;

This might be a good opportunity to bubble up the return value rather 
than just blindly returning -EINVAL. That's really a question for 
Mellanox though.

-Denny

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

* Re: IB/mlx4: Use common error handling code in __mlx4_ib_create_flow()
  2017-10-27  0:33 ` Dennis Dalessandro
@ 2017-10-27  7:34   ` SF Markus Elfring
  2017-10-27 19:36     ` Leon Romanovsky
  2017-10-27 19:44   ` [PATCH] " Leon Romanovsky
  1 sibling, 1 reply; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-27  7:34 UTC (permalink / raw)
  To: Dennis Dalessandro, linux-rdma
  Cc: Doug Ledford, Hal Rosenstock, Leon Romanovsky, Sean Hefty,
	Yishai Hadas, Yuval Shaia, LKML, kernel-janitors

>> Add a jump target so that a bit of exception handling can be better reused
>> at the end of this function.
> 
> I'm not sure this is that big of a win.

Such a view is appropriate because I proposed just another small adjustment
for this source code place.


> I mean you aren't really making the code any smaller

Would anybody like to check corresponding effects in more detail
after a specific function call was replaced by a goto statement?


> and it's not making it any easier to read really.

Is the code readability still good enough there?

Regards,
Markus

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

* Re: IB/mlx4: Use common error handling code in __mlx4_ib_create_flow()
  2017-10-27  7:34   ` SF Markus Elfring
@ 2017-10-27 19:36     ` Leon Romanovsky
  2017-10-30  8:04       ` SF Markus Elfring
  0 siblings, 1 reply; 12+ messages in thread
From: Leon Romanovsky @ 2017-10-27 19:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dennis Dalessandro, linux-rdma, Doug Ledford, Hal Rosenstock,
	Sean Hefty, Yishai Hadas, Yuval Shaia, LKML, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 716 bytes --]

On Fri, Oct 27, 2017 at 09:34:18AM +0200, SF Markus Elfring wrote:
> >> Add a jump target so that a bit of exception handling can be better reused
> >> at the end of this function.
> >
> > I'm not sure this is that big of a win.
>
> Such a view is appropriate because I proposed just another small adjustment
> for this source code place.
>
>
> > I mean you aren't really making the code any smaller
>
> Would anybody like to check corresponding effects in more detail
> after a specific function call was replaced by a goto statement?

You are supposed to do it and not "anybody".

>
>
> > and it's not making it any easier to read really.
>
> Is the code readability still good enough there?
>
> Regards,
> Markus

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] IB/mlx4: Use common error handling code in __mlx4_ib_create_flow()
  2017-10-26 16:12 [PATCH] IB/mlx4: Use common error handling code in __mlx4_ib_create_flow() SF Markus Elfring
  2017-10-27  0:33 ` Dennis Dalessandro
@ 2017-10-27 19:39 ` Leon Romanovsky
  2017-10-27 20:53   ` SF Markus Elfring
  1 sibling, 1 reply; 12+ messages in thread
From: Leon Romanovsky @ 2017-10-27 19:39 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Dennis Dalessandro, Doug Ledford, Hal Rosenstock,
	Sean Hefty, Yishai Hadas, Yuval Shaia, LKML, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 713 bytes --]

On Thu, Oct 26, 2017 at 06:12:31PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 26 Oct 2017 17:54:15 +0200
>
> Add a jump target so that a bit of exception handling can be better reused
> at the end of this function.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/infiniband/hw/mlx4/main.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>

Doug,

I would like to refresh my request, please don't take ANY patches
for mlx4/mlx5/rxe from Markus without explicit acknowledge from our
side.

This change adds nothing except code churn.

Thanks

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] IB/mlx4: Use common error handling code in __mlx4_ib_create_flow()
  2017-10-27  0:33 ` Dennis Dalessandro
  2017-10-27  7:34   ` SF Markus Elfring
@ 2017-10-27 19:44   ` Leon Romanovsky
  1 sibling, 0 replies; 12+ messages in thread
From: Leon Romanovsky @ 2017-10-27 19:44 UTC (permalink / raw)
  To: Dennis Dalessandro
  Cc: SF Markus Elfring, linux-rdma, Doug Ledford, Hal Rosenstock,
	Sean Hefty, Yishai Hadas, Yuval Shaia, LKML, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1644 bytes --]

On Thu, Oct 26, 2017 at 08:33:39PM -0400, Dennis Dalessandro wrote:
> On 10/26/2017 12:12 PM, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Thu, 26 Oct 2017 17:54:15 +0200
> >
> > Add a jump target so that a bit of exception handling can be better reused
> > at the end of this function.
>
> I'm not sure this is that big of a win. I mean you aren't really making the
> code any smaller and it's not making it any easier to read really.
>
> > This issue was detected by using the Coccinelle software.
>
> Assuming there was no testing done for this?
>
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> >   drivers/infiniband/hw/mlx4/main.c | 10 +++++-----
> >   1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> > index c636842c5be0..4a598c48ea1c 100644
> > --- a/drivers/infiniband/hw/mlx4/main.c
> > +++ b/drivers/infiniband/hw/mlx4/main.c
> > @@ -1691,8 +1691,8 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
> >   				mdev, qp, default_table + default_flow,
> >   				mailbox->buf + size);
> >   		if (ret < 0) {
> > -			mlx4_free_cmd_mailbox(mdev->dev, mailbox);
> > -			return -EINVAL;
> > +			ret = -EINVAL;
> > +			goto free_mailbox;
>
> This might be a good opportunity to bubble up the return value rather than
> just blindly returning -EINVAL. That's really a question for Mellanox
> though.

It is worth to check it, especially for parse_flow_attr() which can
return -ENOTSUPP (need to fix return -EOPNOTSUPP).

Thanks


>
> -Denny

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: IB/mlx4: Use common error handling code in __mlx4_ib_create_flow()
  2017-10-27 19:39 ` Leon Romanovsky
@ 2017-10-27 20:53   ` SF Markus Elfring
  2017-10-27 21:54     ` Dennis Dalessandro
  0 siblings, 1 reply; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-27 20:53 UTC (permalink / raw)
  To: Leon Romanovsky, Doug Ledford, linux-rdma
  Cc: Dennis Dalessandro, Hal Rosenstock, Sean Hefty, Yishai Hadas,
	Yuval Shaia, LKML, kernel-janitors

> This change adds nothing except code churn.

I guess that the shown change possibility can reduce the object code size
for the affected function.
Do you care for such an detail?

Regards,
Markus

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

* Re: IB/mlx4: Use common error handling code in __mlx4_ib_create_flow()
  2017-10-27 20:53   ` SF Markus Elfring
@ 2017-10-27 21:54     ` Dennis Dalessandro
  2017-10-28  7:39       ` SF Markus Elfring
  0 siblings, 1 reply; 12+ messages in thread
From: Dennis Dalessandro @ 2017-10-27 21:54 UTC (permalink / raw)
  To: SF Markus Elfring, Leon Romanovsky, Doug Ledford, linux-rdma
  Cc: Hal Rosenstock, Sean Hefty, Yishai Hadas, Yuval Shaia, LKML,
	kernel-janitors

On 10/27/2017 4:53 PM, SF Markus Elfring wrote:
>> This change adds nothing except code churn.
> 
> I guess that the shown change possibility can reduce the object code size
> for the affected function.
> Do you care for such an detail?
> 
> Regards,
> Markus
> 

You guess? Well perhaps you should find out for certain. Is it an 
appreciable impact?

-Denny

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

* Re: IB/mlx4: Use common error handling code in __mlx4_ib_create_flow()
  2017-10-27 21:54     ` Dennis Dalessandro
@ 2017-10-28  7:39       ` SF Markus Elfring
  0 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-28  7:39 UTC (permalink / raw)
  To: Dennis Dalessandro, linux-rdma
  Cc: Leon Romanovsky, Doug Ledford, Hal Rosenstock, Sean Hefty,
	Yishai Hadas, Yuval Shaia, LKML, kernel-janitors

>> I guess that the shown change possibility can reduce the object code size
>> for the affected function.
> You guess?

I am convinced somehow!

 
> Well perhaps you should find out for certain.

I am trying to point another general implementation detail out:
A jump to an existing call of a function like “mlx4_free_cmd_mailbox”
can be useful if you would like to optimise also this software for
smaller code size.

Are you looking for an information source which you would trust
more (than me)?


> Is it an appreciable impact?

I hope so.

But I showed only the replacement of two function calls here.
I am curious if you care for a small effect at a special place.

A similar refactoring can have a bigger influence in other
software modules, can't it?


There might be an other useful side effect. My concrete proposal
can be questionable as usual.
It seems that the software development attention was increased
a bit so that contributors started thinking about the relevance
of the error code “-EINVAL” at another source code place again.

Regards,
Markus

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

* Re: IB/mlx4: Use common error handling code in __mlx4_ib_create_flow()
  2017-10-27 19:36     ` Leon Romanovsky
@ 2017-10-30  8:04       ` SF Markus Elfring
  2017-10-30  8:34         ` Leon Romanovsky
  0 siblings, 1 reply; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-30  8:04 UTC (permalink / raw)
  To: Leon Romanovsky, Dennis Dalessandro, Doug Ledford, linux-rdma
  Cc: Hal Rosenstock, Sean Hefty, Yishai Hadas, Yuval Shaia, LKML,
	kernel-janitors

>>> I mean you aren't really making the code any smaller
>>
>> Would anybody like to check corresponding effects in more detail
>> after a specific function call was replaced by a goto statement?
> 
> You are supposed to do it and not "anybody".

I can offer another bit of information for this software development discussion.

The following build settings were active in my “Makefile” for this Linux test case.

…
HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O0 -fomit-frame-pointer -std=gnu89
…


The affected source file can be compiled for the processor architecture “x86_64”
by a tool like “GCC 6.4.1+r251631-1.3” from the software distribution
“openSUSE Tumbleweed” with the following command example.

my_cc=/usr/bin/gcc-6 \
&& my_module=drivers/infiniband/hw/mlx4/main.o \
&& git checkout next-20171009 \
&& make -j4 CC="${my_cc}" HOSTCC="${my_cc}" allmodconfig "${my_module}" \
&& size "${my_module}" \
&& git checkout next_fine-tuning_in_mlx4_1 \
&& make -j4 CC="${my_cc}" HOSTCC="${my_cc}" allmodconfig "${my_module}" \
&& size "${my_module}"


Do you find the following details useful for further clarification?

text: -32
data: 0
bss:  0

Regards,
Markus

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

* Re: IB/mlx4: Use common error handling code in __mlx4_ib_create_flow()
  2017-10-30  8:04       ` SF Markus Elfring
@ 2017-10-30  8:34         ` Leon Romanovsky
  2017-10-30  8:47           ` SF Markus Elfring
  0 siblings, 1 reply; 12+ messages in thread
From: Leon Romanovsky @ 2017-10-30  8:34 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dennis Dalessandro, Doug Ledford, linux-rdma, Hal Rosenstock,
	Sean Hefty, Yishai Hadas, Yuval Shaia, LKML, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1483 bytes --]

On Mon, Oct 30, 2017 at 09:04:36AM +0100, SF Markus Elfring wrote:
> >>> I mean you aren't really making the code any smaller
> >>
> >> Would anybody like to check corresponding effects in more detail
> >> after a specific function call was replaced by a goto statement?
> >
> > You are supposed to do it and not "anybody".
>
> I can offer another bit of information for this software development discussion.
>
> The following build settings were active in my “Makefile” for this Linux test case.
>
> …
> HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O0 -fomit-frame-pointer -std=gnu89
> …
>
>
> The affected source file can be compiled for the processor architecture “x86_64”
> by a tool like “GCC 6.4.1+r251631-1.3” from the software distribution
> “openSUSE Tumbleweed” with the following command example.
>
> my_cc=/usr/bin/gcc-6 \
> && my_module=drivers/infiniband/hw/mlx4/main.o \
> && git checkout next-20171009 \
> && make -j4 CC="${my_cc}" HOSTCC="${my_cc}" allmodconfig "${my_module}" \
> && size "${my_module}" \
> && git checkout next_fine-tuning_in_mlx4_1 \
> && make -j4 CC="${my_cc}" HOSTCC="${my_cc}" allmodconfig "${my_module}" \
> && size "${my_module}"
>
>
> Do you find the following details useful for further clarification?

Almost, you should compare sizes of mlx4_ib.ko and not drivers/infiniband/hw/mlx4/main.o.

Thanks

>
> text: -32
> data: 0
> bss:  0
>
> Regards,
> Markus

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: IB/mlx4: Use common error handling code in __mlx4_ib_create_flow()
  2017-10-30  8:34         ` Leon Romanovsky
@ 2017-10-30  8:47           ` SF Markus Elfring
  0 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-30  8:47 UTC (permalink / raw)
  To: Leon Romanovsky, Dennis Dalessandro, Doug Ledford, linux-rdma
  Cc: Hal Rosenstock, Sean Hefty, Yishai Hadas, Yuval Shaia, LKML,
	kernel-janitors

>> Do you find the following details useful for further clarification?
> 
> Almost, you should compare sizes of mlx4_ib.ko and not drivers/infiniband/hw/mlx4/main.o.

text: -32
data: 0
bss:  0


The determined difference is the same finally.

Regards,
Markus

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

end of thread, other threads:[~2017-10-30  8:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-26 16:12 [PATCH] IB/mlx4: Use common error handling code in __mlx4_ib_create_flow() SF Markus Elfring
2017-10-27  0:33 ` Dennis Dalessandro
2017-10-27  7:34   ` SF Markus Elfring
2017-10-27 19:36     ` Leon Romanovsky
2017-10-30  8:04       ` SF Markus Elfring
2017-10-30  8:34         ` Leon Romanovsky
2017-10-30  8:47           ` SF Markus Elfring
2017-10-27 19:44   ` [PATCH] " Leon Romanovsky
2017-10-27 19:39 ` Leon Romanovsky
2017-10-27 20:53   ` SF Markus Elfring
2017-10-27 21:54     ` Dennis Dalessandro
2017-10-28  7:39       ` SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).