All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink()
@ 2017-07-04 18:34 Gustavo A. R. Silva
  2017-07-21  7:36 ` Juergen Gross
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-04 18:34 UTC (permalink / raw)
  To: Boris Ostrovsky, Juergen Gross
  Cc: xen-devel, linux-kernel, Gustavo A. R. Silva

Remove unnecessary static on local variables last_frontswap_pages and
tgt_frontswap_pages. Such variables are initialized before being used,
on every execution path throughout the function. The statics have no
benefit and, removing them reduce the code 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;

You can see a significant difference in the code size after executing
the size command, before and after the code change:

before:
   text	   data	    bss	    dec	    hex	filename
   5633	   3452	    384	   9469	   24fd	drivers/xen/xen-selfballoon.o

after:
   text	   data	    bss	    dec	    hex	filename
   5576	   3308	    256	   9140	   23b4	drivers/xen/xen-selfballoon.o

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/xen/xen-selfballoon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/xen/xen-selfballoon.c b/drivers/xen/xen-selfballoon.c
index 6662071..a67e955 100644
--- a/drivers/xen/xen-selfballoon.c
+++ b/drivers/xen/xen-selfballoon.c
@@ -151,8 +151,8 @@ static unsigned long frontswap_inertia_counter;
 static void frontswap_selfshrink(void)
 {
 	static unsigned long cur_frontswap_pages;
-	static unsigned long last_frontswap_pages;
-	static unsigned long tgt_frontswap_pages;
+	unsigned long last_frontswap_pages;
+	unsigned long tgt_frontswap_pages;
 
 	last_frontswap_pages = cur_frontswap_pages;
 	cur_frontswap_pages = frontswap_curr_pages();
-- 
2.5.0

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

* [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink()
@ 2017-07-04 18:34 Gustavo A. R. Silva
  0 siblings, 0 replies; 8+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-04 18:34 UTC (permalink / raw)
  To: Boris Ostrovsky, Juergen Gross
  Cc: xen-devel, Gustavo A. R. Silva, linux-kernel

Remove unnecessary static on local variables last_frontswap_pages and
tgt_frontswap_pages. Such variables are initialized before being used,
on every execution path throughout the function. The statics have no
benefit and, removing them reduce the code 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;

You can see a significant difference in the code size after executing
the size command, before and after the code change:

before:
   text	   data	    bss	    dec	    hex	filename
   5633	   3452	    384	   9469	   24fd	drivers/xen/xen-selfballoon.o

after:
   text	   data	    bss	    dec	    hex	filename
   5576	   3308	    256	   9140	   23b4	drivers/xen/xen-selfballoon.o

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/xen/xen-selfballoon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/xen/xen-selfballoon.c b/drivers/xen/xen-selfballoon.c
index 6662071..a67e955 100644
--- a/drivers/xen/xen-selfballoon.c
+++ b/drivers/xen/xen-selfballoon.c
@@ -151,8 +151,8 @@ static unsigned long frontswap_inertia_counter;
 static void frontswap_selfshrink(void)
 {
 	static unsigned long cur_frontswap_pages;
-	static unsigned long last_frontswap_pages;
-	static unsigned long tgt_frontswap_pages;
+	unsigned long last_frontswap_pages;
+	unsigned long tgt_frontswap_pages;
 
 	last_frontswap_pages = cur_frontswap_pages;
 	cur_frontswap_pages = frontswap_curr_pages();
-- 
2.5.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink()
  2017-07-04 18:34 [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink() Gustavo A. R. Silva
@ 2017-07-21  7:36 ` Juergen Gross
  2017-07-21 20:46   ` Gustavo A. R. Silva
  2017-07-21 20:46   ` Gustavo A. R. Silva
  2017-07-21  7:36 ` Juergen Gross
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 8+ messages in thread
From: Juergen Gross @ 2017-07-21  7:36 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Boris Ostrovsky; +Cc: xen-devel, linux-kernel

On 04/07/17 20:34, Gustavo A. R. Silva wrote:
> Remove unnecessary static on local variables last_frontswap_pages and
> tgt_frontswap_pages. Such variables are initialized before being used,
> on every execution path throughout the function. The statics have no
> benefit and, removing them reduce the code 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;
> 
> You can see a significant difference in the code size after executing
> the size command, before and after the code change:
> 
> before:
>    text	   data	    bss	    dec	    hex	filename
>    5633	   3452	    384	   9469	   24fd	drivers/xen/xen-selfballoon.o
> 
> after:
>    text	   data	    bss	    dec	    hex	filename
>    5576	   3308	    256	   9140	   23b4	drivers/xen/xen-selfballoon.o
> 
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Sorry for late answer,

Juergen

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

* Re: [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink()
  2017-07-04 18:34 [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink() Gustavo A. R. Silva
  2017-07-21  7:36 ` Juergen Gross
@ 2017-07-21  7:36 ` Juergen Gross
  2017-07-28  9:34 ` Juergen Gross
  2017-07-28  9:34 ` Juergen Gross
  3 siblings, 0 replies; 8+ messages in thread
From: Juergen Gross @ 2017-07-21  7:36 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Boris Ostrovsky; +Cc: xen-devel, linux-kernel

On 04/07/17 20:34, Gustavo A. R. Silva wrote:
> Remove unnecessary static on local variables last_frontswap_pages and
> tgt_frontswap_pages. Such variables are initialized before being used,
> on every execution path throughout the function. The statics have no
> benefit and, removing them reduce the code 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;
> 
> You can see a significant difference in the code size after executing
> the size command, before and after the code change:
> 
> before:
>    text	   data	    bss	    dec	    hex	filename
>    5633	   3452	    384	   9469	   24fd	drivers/xen/xen-selfballoon.o
> 
> after:
>    text	   data	    bss	    dec	    hex	filename
>    5576	   3308	    256	   9140	   23b4	drivers/xen/xen-selfballoon.o
> 
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Sorry for late answer,

Juergen

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink()
  2017-07-21  7:36 ` Juergen Gross
@ 2017-07-21 20:46   ` Gustavo A. R. Silva
  2017-07-21 20:46   ` Gustavo A. R. Silva
  1 sibling, 0 replies; 8+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-21 20:46 UTC (permalink / raw)
  To: Juergen Gross, Boris Ostrovsky; +Cc: xen-devel, linux-kernel

Hi Juergen,

On 07/21/2017 02:36 AM, Juergen Gross wrote:
> On 04/07/17 20:34, Gustavo A. R. Silva wrote:
>> Remove unnecessary static on local variables last_frontswap_pages and
>> tgt_frontswap_pages. Such variables are initialized before being used,
>> on every execution path throughout the function. The statics have no
>> benefit and, removing them reduce the code 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;
>>
>> You can see a significant difference in the code size after executing
>> the size command, before and after the code change:
>>
>> before:
>>    text	   data	    bss	    dec	    hex	filename
>>    5633	   3452	    384	   9469	   24fd	drivers/xen/xen-selfballoon.o
>>
>> after:
>>    text	   data	    bss	    dec	    hex	filename
>>    5576	   3308	    256	   9140	   23b4	drivers/xen/xen-selfballoon.o
>>
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>
> Reviewed-by: Juergen Gross <jgross@suse.com>
>

Thank you!

-- 
Gustavo A. R. Silva

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

* Re: [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink()
  2017-07-21  7:36 ` Juergen Gross
  2017-07-21 20:46   ` Gustavo A. R. Silva
@ 2017-07-21 20:46   ` Gustavo A. R. Silva
  1 sibling, 0 replies; 8+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-21 20:46 UTC (permalink / raw)
  To: Juergen Gross, Boris Ostrovsky; +Cc: xen-devel, linux-kernel

Hi Juergen,

On 07/21/2017 02:36 AM, Juergen Gross wrote:
> On 04/07/17 20:34, Gustavo A. R. Silva wrote:
>> Remove unnecessary static on local variables last_frontswap_pages and
>> tgt_frontswap_pages. Such variables are initialized before being used,
>> on every execution path throughout the function. The statics have no
>> benefit and, removing them reduce the code 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;
>>
>> You can see a significant difference in the code size after executing
>> the size command, before and after the code change:
>>
>> before:
>>    text	   data	    bss	    dec	    hex	filename
>>    5633	   3452	    384	   9469	   24fd	drivers/xen/xen-selfballoon.o
>>
>> after:
>>    text	   data	    bss	    dec	    hex	filename
>>    5576	   3308	    256	   9140	   23b4	drivers/xen/xen-selfballoon.o
>>
>> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
>
> Reviewed-by: Juergen Gross <jgross@suse.com>
>

Thank you!

-- 
Gustavo A. R. Silva

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink()
  2017-07-04 18:34 [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink() Gustavo A. R. Silva
  2017-07-21  7:36 ` Juergen Gross
  2017-07-21  7:36 ` Juergen Gross
@ 2017-07-28  9:34 ` Juergen Gross
  2017-07-28  9:34 ` Juergen Gross
  3 siblings, 0 replies; 8+ messages in thread
From: Juergen Gross @ 2017-07-28  9:34 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Boris Ostrovsky; +Cc: xen-devel, linux-kernel

On 04/07/17 20:34, Gustavo A. R. Silva wrote:
> Remove unnecessary static on local variables last_frontswap_pages and
> tgt_frontswap_pages. Such variables are initialized before being used,
> on every execution path throughout the function. The statics have no
> benefit and, removing them reduce the code 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;
> 
> You can see a significant difference in the code size after executing
> the size command, before and after the code change:
> 
> before:
>    text	   data	    bss	    dec	    hex	filename
>    5633	   3452	    384	   9469	   24fd	drivers/xen/xen-selfballoon.o
> 
> after:
>    text	   data	    bss	    dec	    hex	filename
>    5576	   3308	    256	   9140	   23b4	drivers/xen/xen-selfballoon.o
> 
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>

Committed to xen/tip.git for-linus-4.13b


Thanks,

Juergen

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

* Re: [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink()
  2017-07-04 18:34 [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink() Gustavo A. R. Silva
                   ` (2 preceding siblings ...)
  2017-07-28  9:34 ` Juergen Gross
@ 2017-07-28  9:34 ` Juergen Gross
  3 siblings, 0 replies; 8+ messages in thread
From: Juergen Gross @ 2017-07-28  9:34 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Boris Ostrovsky; +Cc: xen-devel, linux-kernel

On 04/07/17 20:34, Gustavo A. R. Silva wrote:
> Remove unnecessary static on local variables last_frontswap_pages and
> tgt_frontswap_pages. Such variables are initialized before being used,
> on every execution path throughout the function. The statics have no
> benefit and, removing them reduce the code 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;
> 
> You can see a significant difference in the code size after executing
> the size command, before and after the code change:
> 
> before:
>    text	   data	    bss	    dec	    hex	filename
>    5633	   3452	    384	   9469	   24fd	drivers/xen/xen-selfballoon.o
> 
> after:
>    text	   data	    bss	    dec	    hex	filename
>    5576	   3308	    256	   9140	   23b4	drivers/xen/xen-selfballoon.o
> 
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>

Committed to xen/tip.git for-linus-4.13b


Thanks,

Juergen


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

end of thread, other threads:[~2017-07-28  9:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-04 18:34 [PATCH] xen: selfballoon: remove unnecessary static in frontswap_selfshrink() Gustavo A. R. Silva
2017-07-21  7:36 ` Juergen Gross
2017-07-21 20:46   ` Gustavo A. R. Silva
2017-07-21 20:46   ` Gustavo A. R. Silva
2017-07-21  7:36 ` Juergen Gross
2017-07-28  9:34 ` Juergen Gross
2017-07-28  9:34 ` Juergen Gross
  -- strict thread matches above, loose matches on Subject: below --
2017-07-04 18:34 Gustavo A. R. Silva

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.