All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] liquidio: lio_vf_main: remove unnecessary static in setup_io_queues()
@ 2017-07-18 20:50 Gustavo A. R. Silva
  2017-07-18 21:05 ` Felix Manlunas
  2017-07-19 23:35 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-18 20:50 UTC (permalink / raw)
  To: Derek Chickles, Satanand Burla, Felix Manlunas, Raghu Vatsavayi
  Cc: netdev, linux-kernel, Gustavo A. R. Silva

Remove unnecessary static on local variables cpu_id_modulus and cpu_id.
Such variables are initialized before being used, on every execution
path throughout the function. The static has no benefit and, removing
it reduces the object file size.

This issue was detected using Coccinelle and the following semantic patch:

@bad exists@
position p;
identifier x;
type T;
@@

static T x@p;
...
x = <+...x...+>

@@
identifier x;
expression e;
type T;
position p != bad.p;
@@

-static
 T x@p;
 ... when != x
     when strict
?x = e;

In the following log you can see a significant difference in the object
file size. Also, there is a significant difference in the bss segment.
This log is the output of the size command, before and after the code
change:

before:
   text    data     bss     dec     hex filename
  55656   10680     576   66912   10560 drivers/net/ethernet/cavium/liquidio/lio_vf_main.o

after:
   text    data     bss     dec     hex filename
  55796   10536     448   66780   104dc drivers/net/ethernet/cavium/liquidio/lio_vf_main.o

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 9b24710..935ff29 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -1663,10 +1663,10 @@ static int setup_io_queues(struct octeon_device *octeon_dev, int ifidx)
 {
 	struct octeon_droq_ops droq_ops;
 	struct net_device *netdev;
-	static int cpu_id_modulus;
+	int cpu_id_modulus;
 	struct octeon_droq *droq;
 	struct napi_struct *napi;
-	static int cpu_id;
+	int cpu_id;
 	int num_tx_descs;
 	struct lio *lio;
 	int retval = 0;
-- 
2.5.0

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

* Re: [PATCH] liquidio: lio_vf_main: remove unnecessary static in setup_io_queues()
  2017-07-18 20:50 [PATCH] liquidio: lio_vf_main: remove unnecessary static in setup_io_queues() Gustavo A. R. Silva
@ 2017-07-18 21:05 ` Felix Manlunas
  2017-07-19 23:35 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Felix Manlunas @ 2017-07-18 21:05 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Derek Chickles, Satanand Burla, Felix Manlunas, Raghu Vatsavayi,
	netdev, linux-kernel

On Tue, Jul 18, 2017 at 03:50:15PM -0500, Gustavo A. R. Silva wrote:
> Remove unnecessary static on local variables cpu_id_modulus and cpu_id.
> Such variables are initialized before being used, on every execution
> path throughout the function. The static has no benefit and, removing
> it reduces the object file size.
> 
> This issue was detected using Coccinelle and the following semantic patch:
> 
> @bad exists@
> position p;
> identifier x;
> type T;
> @@
> 
> static T x@p;
> ...
> x = <+...x...+>
> 
> @@
> identifier x;
> expression e;
> type T;
> position p != bad.p;
> @@
> 
> -static
>  T x@p;
>  ... when != x
>      when strict
> ?x = e;
> 
> In the following log you can see a significant difference in the object
> file size. Also, there is a significant difference in the bss segment.
> This log is the output of the size command, before and after the code
> change:
> 
> before:
>    text    data     bss     dec     hex filename
>   55656   10680     576   66912   10560 drivers/net/ethernet/cavium/liquidio/lio_vf_main.o
> 
> after:
>    text    data     bss     dec     hex filename
>   55796   10536     448   66780   104dc drivers/net/ethernet/cavium/liquidio/lio_vf_main.o
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
>  drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
> index 9b24710..935ff29 100644
> --- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
> +++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
> @@ -1663,10 +1663,10 @@ static int setup_io_queues(struct octeon_device *octeon_dev, int ifidx)
>  {
>  	struct octeon_droq_ops droq_ops;
>  	struct net_device *netdev;
> -	static int cpu_id_modulus;
> +	int cpu_id_modulus;
>  	struct octeon_droq *droq;
>  	struct napi_struct *napi;
> -	static int cpu_id;
> +	int cpu_id;
>  	int num_tx_descs;
>  	struct lio *lio;
>  	int retval = 0;
> -- 
> 2.5.0
> 

Thanks.

Acked-by: Felix Manlunas <felix.manlunas@cavium.com>

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

* Re: [PATCH] liquidio: lio_vf_main: remove unnecessary static in setup_io_queues()
  2017-07-18 20:50 [PATCH] liquidio: lio_vf_main: remove unnecessary static in setup_io_queues() Gustavo A. R. Silva
  2017-07-18 21:05 ` Felix Manlunas
@ 2017-07-19 23:35 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-07-19 23:35 UTC (permalink / raw)
  To: gustavo
  Cc: derek.chickles, satananda.burla, felix.manlunas, raghu.vatsavayi,
	netdev, linux-kernel

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Tue, 18 Jul 2017 15:50:15 -0500

> Remove unnecessary static on local variables cpu_id_modulus and cpu_id.
> Such variables are initialized before being used, on every execution
> path throughout the function. The static has no benefit and, removing
> it reduces the object file size.
> 
> This issue was detected using Coccinelle and the following semantic patch:
 ...
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied.

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

end of thread, other threads:[~2017-07-19 23:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-18 20:50 [PATCH] liquidio: lio_vf_main: remove unnecessary static in setup_io_queues() Gustavo A. R. Silva
2017-07-18 21:05 ` Felix Manlunas
2017-07-19 23:35 ` David Miller

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.