Skip to contentSkip to conversation

xen: selfballoon: remove unnecessary static in frontswap_selfshrink()

PATCH In review Gustavo A. R. Silva 2 participants 7 messages Jul 4, 2017 – Jul 28, 2017 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: selfballoon: remove unnecessary static in frontswap_selfshrink()

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
---
 drivers/xen/xen-selfballoon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/xen-selfballoon.c +2 -2
index 6662071..a67e955 100644
@@ -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();
Signature · 1 line
2.5.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 34 lines · 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:

Quoted 8 lines
   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

Sorry for late answer,

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Gustavo A. R. Silva
Quoted 34 lines · 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:

Quoted 8 lines
   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

Sorry for late answer,

Juergen

#3 lore raw

Hi Juergen,

Quoted 38 lines · Juergen Gross
Quoted 37 lines · 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
Quoted 8 lines
Quoted 5 lines

after:

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

Thank you!

Signature · 1 line
Gustavo A. R. Silva
#4 lore raw
In reply to Juergen Gross

Hi Juergen,

Quoted 38 lines · Juergen Gross
Quoted 37 lines · 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
Quoted 8 lines
Quoted 5 lines

after:

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

Thank you!

Signature · 6 lines
Gustavo A. R. Silva

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
maintainer
#5 lore raw
In reply to Gustavo A. R. Silva
Quoted 34 lines · 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:

Quoted 8 lines
   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

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

Thanks,

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

maintainer
#6 lore raw
In reply to Gustavo A. R. Silva
Quoted 34 lines · 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:

Quoted 8 lines
   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

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

Thanks,

Juergen