All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] reduce stack usage of node_read_meminfo()
@ 2010-07-08  9:20 ` KOSAKI Motohiro
  0 siblings, 0 replies; 10+ messages in thread
From: KOSAKI Motohiro @ 2010-07-08  9:20 UTC (permalink / raw)
  To: LKML, linux-mm, Andrew Morton; +Cc: kosaki.motohiro


Now, cmpilation node_read_meminfo() output following warning. Because
it has very large sprintf() argument.

	drivers/base/node.c: In function 'node_read_meminfo':
	drivers/base/node.c:139: warning: the frame size of 848 bytes is
	larger than 512 bytes

This patch fixes it by splitting sprintf() in three parts.
It doesn't have functional change.


Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
 drivers/base/node.c |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/base/node.c b/drivers/base/node.c
index 2bdd8a9..a0fb2ef 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -66,8 +66,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
 	struct sysinfo i;
 
 	si_meminfo_node(&i, nid);
-
-	n = sprintf(buf, "\n"
+	n = sprintf(buf,
 		       "Node %d MemTotal:       %8lu kB\n"
 		       "Node %d MemFree:        %8lu kB\n"
 		       "Node %d MemUsed:        %8lu kB\n"
@@ -78,13 +77,33 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
 		       "Node %d Active(file):   %8lu kB\n"
 		       "Node %d Inactive(file): %8lu kB\n"
 		       "Node %d Unevictable:    %8lu kB\n"
-		       "Node %d Mlocked:        %8lu kB\n"
+		       "Node %d Mlocked:        %8lu kB\n",
+		       nid, K(i.totalram),
+		       nid, K(i.freeram),
+		       nid, K(i.totalram - i.freeram),
+		       nid, K(node_page_state(nid, NR_ACTIVE_ANON) +
+				node_page_state(nid, NR_ACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_INACTIVE_ANON) +
+				node_page_state(nid, NR_INACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_ACTIVE_ANON)),
+		       nid, K(node_page_state(nid, NR_INACTIVE_ANON)),
+		       nid, K(node_page_state(nid, NR_ACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_INACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_UNEVICTABLE)),
+		       nid, K(node_page_state(nid, NR_MLOCK)));
+
 #ifdef CONFIG_HIGHMEM
+	n += sprintf(buf,
 		       "Node %d HighTotal:      %8lu kB\n"
 		       "Node %d HighFree:       %8lu kB\n"
 		       "Node %d LowTotal:       %8lu kB\n"
-		       "Node %d LowFree:        %8lu kB\n"
+		       "Node %d LowFree:        %8lu kB\n",
+		       nid, K(i.totalhigh),
+		       nid, K(i.freehigh),
+		       nid, K(i.totalram - i.totalhigh),
+		       nid, K(i.freeram - i.freehigh));
 #endif
+	n += sprintf(buf,
 		       "Node %d Dirty:          %8lu kB\n"
 		       "Node %d Writeback:      %8lu kB\n"
 		       "Node %d FilePages:      %8lu kB\n"
@@ -99,25 +118,6 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
 		       "Node %d Slab:           %8lu kB\n"
 		       "Node %d SReclaimable:   %8lu kB\n"
 		       "Node %d SUnreclaim:     %8lu kB\n",
-		       nid, K(i.totalram),
-		       nid, K(i.freeram),
-		       nid, K(i.totalram - i.freeram),
-		       nid, K(node_page_state(nid, NR_ACTIVE_ANON) +
-				node_page_state(nid, NR_ACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_INACTIVE_ANON) +
-				node_page_state(nid, NR_INACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_ACTIVE_ANON)),
-		       nid, K(node_page_state(nid, NR_INACTIVE_ANON)),
-		       nid, K(node_page_state(nid, NR_ACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_INACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_UNEVICTABLE)),
-		       nid, K(node_page_state(nid, NR_MLOCK)),
-#ifdef CONFIG_HIGHMEM
-		       nid, K(i.totalhigh),
-		       nid, K(i.freehigh),
-		       nid, K(i.totalram - i.totalhigh),
-		       nid, K(i.freeram - i.freehigh),
-#endif
 		       nid, K(node_page_state(nid, NR_FILE_DIRTY)),
 		       nid, K(node_page_state(nid, NR_WRITEBACK)),
 		       nid, K(node_page_state(nid, NR_FILE_PAGES)),
-- 
1.6.5.2




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

* [PATCH] reduce stack usage of node_read_meminfo()
@ 2010-07-08  9:20 ` KOSAKI Motohiro
  0 siblings, 0 replies; 10+ messages in thread
From: KOSAKI Motohiro @ 2010-07-08  9:20 UTC (permalink / raw)
  To: LKML, linux-mm, Andrew Morton; +Cc: kosaki.motohiro


Now, cmpilation node_read_meminfo() output following warning. Because
it has very large sprintf() argument.

	drivers/base/node.c: In function 'node_read_meminfo':
	drivers/base/node.c:139: warning: the frame size of 848 bytes is
	larger than 512 bytes

This patch fixes it by splitting sprintf() in three parts.
It doesn't have functional change.


Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
 drivers/base/node.c |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/base/node.c b/drivers/base/node.c
index 2bdd8a9..a0fb2ef 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -66,8 +66,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
 	struct sysinfo i;
 
 	si_meminfo_node(&i, nid);
-
-	n = sprintf(buf, "\n"
+	n = sprintf(buf,
 		       "Node %d MemTotal:       %8lu kB\n"
 		       "Node %d MemFree:        %8lu kB\n"
 		       "Node %d MemUsed:        %8lu kB\n"
@@ -78,13 +77,33 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
 		       "Node %d Active(file):   %8lu kB\n"
 		       "Node %d Inactive(file): %8lu kB\n"
 		       "Node %d Unevictable:    %8lu kB\n"
-		       "Node %d Mlocked:        %8lu kB\n"
+		       "Node %d Mlocked:        %8lu kB\n",
+		       nid, K(i.totalram),
+		       nid, K(i.freeram),
+		       nid, K(i.totalram - i.freeram),
+		       nid, K(node_page_state(nid, NR_ACTIVE_ANON) +
+				node_page_state(nid, NR_ACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_INACTIVE_ANON) +
+				node_page_state(nid, NR_INACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_ACTIVE_ANON)),
+		       nid, K(node_page_state(nid, NR_INACTIVE_ANON)),
+		       nid, K(node_page_state(nid, NR_ACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_INACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_UNEVICTABLE)),
+		       nid, K(node_page_state(nid, NR_MLOCK)));
+
 #ifdef CONFIG_HIGHMEM
+	n += sprintf(buf,
 		       "Node %d HighTotal:      %8lu kB\n"
 		       "Node %d HighFree:       %8lu kB\n"
 		       "Node %d LowTotal:       %8lu kB\n"
-		       "Node %d LowFree:        %8lu kB\n"
+		       "Node %d LowFree:        %8lu kB\n",
+		       nid, K(i.totalhigh),
+		       nid, K(i.freehigh),
+		       nid, K(i.totalram - i.totalhigh),
+		       nid, K(i.freeram - i.freehigh));
 #endif
+	n += sprintf(buf,
 		       "Node %d Dirty:          %8lu kB\n"
 		       "Node %d Writeback:      %8lu kB\n"
 		       "Node %d FilePages:      %8lu kB\n"
@@ -99,25 +118,6 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
 		       "Node %d Slab:           %8lu kB\n"
 		       "Node %d SReclaimable:   %8lu kB\n"
 		       "Node %d SUnreclaim:     %8lu kB\n",
-		       nid, K(i.totalram),
-		       nid, K(i.freeram),
-		       nid, K(i.totalram - i.freeram),
-		       nid, K(node_page_state(nid, NR_ACTIVE_ANON) +
-				node_page_state(nid, NR_ACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_INACTIVE_ANON) +
-				node_page_state(nid, NR_INACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_ACTIVE_ANON)),
-		       nid, K(node_page_state(nid, NR_INACTIVE_ANON)),
-		       nid, K(node_page_state(nid, NR_ACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_INACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_UNEVICTABLE)),
-		       nid, K(node_page_state(nid, NR_MLOCK)),
-#ifdef CONFIG_HIGHMEM
-		       nid, K(i.totalhigh),
-		       nid, K(i.freehigh),
-		       nid, K(i.totalram - i.totalhigh),
-		       nid, K(i.freeram - i.freehigh),
-#endif
 		       nid, K(node_page_state(nid, NR_FILE_DIRTY)),
 		       nid, K(node_page_state(nid, NR_WRITEBACK)),
 		       nid, K(node_page_state(nid, NR_FILE_PAGES)),
-- 
1.6.5.2



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] reduce stack usage of node_read_meminfo()
  2010-07-08  9:20 ` KOSAKI Motohiro
@ 2010-07-08 10:41   ` KOSAKI Motohiro
  -1 siblings, 0 replies; 10+ messages in thread
From: KOSAKI Motohiro @ 2010-07-08 10:41 UTC (permalink / raw)
  To: LKML; +Cc: kosaki.motohiro, linux-mm, Andrew Morton


Grr, I did sent old ver. right patch is here ;-)
sorry.

================================================
Subject: [PATCH] reduce stack usage of node_read_meminfo()

Now, cmpilation node_read_meminfo() output following warning. Because
it has very large sprintf() argument.

	drivers/base/node.c: In function 'node_read_meminfo':
	drivers/base/node.c:139: warning: the frame size of 848 bytes is
	larger than 512 bytes

This patch fixes it by splitting sprintf() in three parts.
This also reduce CONFIG_HIGHMEM mess a bit.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
 drivers/base/node.c |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/base/node.c b/drivers/base/node.c
index 2bdd8a9..2872e86 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -66,8 +66,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
 	struct sysinfo i;
 
 	si_meminfo_node(&i, nid);
-
-	n = sprintf(buf, "\n"
+	n = sprintf(buf,
 		       "Node %d MemTotal:       %8lu kB\n"
 		       "Node %d MemFree:        %8lu kB\n"
 		       "Node %d MemUsed:        %8lu kB\n"
@@ -78,13 +77,33 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
 		       "Node %d Active(file):   %8lu kB\n"
 		       "Node %d Inactive(file): %8lu kB\n"
 		       "Node %d Unevictable:    %8lu kB\n"
-		       "Node %d Mlocked:        %8lu kB\n"
+		       "Node %d Mlocked:        %8lu kB\n",
+		       nid, K(i.totalram),
+		       nid, K(i.freeram),
+		       nid, K(i.totalram - i.freeram),
+		       nid, K(node_page_state(nid, NR_ACTIVE_ANON) +
+				node_page_state(nid, NR_ACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_INACTIVE_ANON) +
+				node_page_state(nid, NR_INACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_ACTIVE_ANON)),
+		       nid, K(node_page_state(nid, NR_INACTIVE_ANON)),
+		       nid, K(node_page_state(nid, NR_ACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_INACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_UNEVICTABLE)),
+		       nid, K(node_page_state(nid, NR_MLOCK)));
+
 #ifdef CONFIG_HIGHMEM
+	n += sprintf(buf + n,
 		       "Node %d HighTotal:      %8lu kB\n"
 		       "Node %d HighFree:       %8lu kB\n"
 		       "Node %d LowTotal:       %8lu kB\n"
-		       "Node %d LowFree:        %8lu kB\n"
+		       "Node %d LowFree:        %8lu kB\n",
+		       nid, K(i.totalhigh),
+		       nid, K(i.freehigh),
+		       nid, K(i.totalram - i.totalhigh),
+		       nid, K(i.freeram - i.freehigh));
 #endif
+	n += sprintf(buf + n,
 		       "Node %d Dirty:          %8lu kB\n"
 		       "Node %d Writeback:      %8lu kB\n"
 		       "Node %d FilePages:      %8lu kB\n"
@@ -99,25 +118,6 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
 		       "Node %d Slab:           %8lu kB\n"
 		       "Node %d SReclaimable:   %8lu kB\n"
 		       "Node %d SUnreclaim:     %8lu kB\n",
-		       nid, K(i.totalram),
-		       nid, K(i.freeram),
-		       nid, K(i.totalram - i.freeram),
-		       nid, K(node_page_state(nid, NR_ACTIVE_ANON) +
-				node_page_state(nid, NR_ACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_INACTIVE_ANON) +
-				node_page_state(nid, NR_INACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_ACTIVE_ANON)),
-		       nid, K(node_page_state(nid, NR_INACTIVE_ANON)),
-		       nid, K(node_page_state(nid, NR_ACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_INACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_UNEVICTABLE)),
-		       nid, K(node_page_state(nid, NR_MLOCK)),
-#ifdef CONFIG_HIGHMEM
-		       nid, K(i.totalhigh),
-		       nid, K(i.freehigh),
-		       nid, K(i.totalram - i.totalhigh),
-		       nid, K(i.freeram - i.freehigh),
-#endif
 		       nid, K(node_page_state(nid, NR_FILE_DIRTY)),
 		       nid, K(node_page_state(nid, NR_WRITEBACK)),
 		       nid, K(node_page_state(nid, NR_FILE_PAGES)),
-- 
1.6.5.2




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

* Re: [PATCH] reduce stack usage of node_read_meminfo()
@ 2010-07-08 10:41   ` KOSAKI Motohiro
  0 siblings, 0 replies; 10+ messages in thread
From: KOSAKI Motohiro @ 2010-07-08 10:41 UTC (permalink / raw)
  To: LKML; +Cc: kosaki.motohiro, linux-mm, Andrew Morton


Grr, I did sent old ver. right patch is here ;-)
sorry.

================================================
Subject: [PATCH] reduce stack usage of node_read_meminfo()

Now, cmpilation node_read_meminfo() output following warning. Because
it has very large sprintf() argument.

	drivers/base/node.c: In function 'node_read_meminfo':
	drivers/base/node.c:139: warning: the frame size of 848 bytes is
	larger than 512 bytes

This patch fixes it by splitting sprintf() in three parts.
This also reduce CONFIG_HIGHMEM mess a bit.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
 drivers/base/node.c |   46 +++++++++++++++++++++++-----------------------
 1 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/base/node.c b/drivers/base/node.c
index 2bdd8a9..2872e86 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -66,8 +66,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
 	struct sysinfo i;
 
 	si_meminfo_node(&i, nid);
-
-	n = sprintf(buf, "\n"
+	n = sprintf(buf,
 		       "Node %d MemTotal:       %8lu kB\n"
 		       "Node %d MemFree:        %8lu kB\n"
 		       "Node %d MemUsed:        %8lu kB\n"
@@ -78,13 +77,33 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
 		       "Node %d Active(file):   %8lu kB\n"
 		       "Node %d Inactive(file): %8lu kB\n"
 		       "Node %d Unevictable:    %8lu kB\n"
-		       "Node %d Mlocked:        %8lu kB\n"
+		       "Node %d Mlocked:        %8lu kB\n",
+		       nid, K(i.totalram),
+		       nid, K(i.freeram),
+		       nid, K(i.totalram - i.freeram),
+		       nid, K(node_page_state(nid, NR_ACTIVE_ANON) +
+				node_page_state(nid, NR_ACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_INACTIVE_ANON) +
+				node_page_state(nid, NR_INACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_ACTIVE_ANON)),
+		       nid, K(node_page_state(nid, NR_INACTIVE_ANON)),
+		       nid, K(node_page_state(nid, NR_ACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_INACTIVE_FILE)),
+		       nid, K(node_page_state(nid, NR_UNEVICTABLE)),
+		       nid, K(node_page_state(nid, NR_MLOCK)));
+
 #ifdef CONFIG_HIGHMEM
+	n += sprintf(buf + n,
 		       "Node %d HighTotal:      %8lu kB\n"
 		       "Node %d HighFree:       %8lu kB\n"
 		       "Node %d LowTotal:       %8lu kB\n"
-		       "Node %d LowFree:        %8lu kB\n"
+		       "Node %d LowFree:        %8lu kB\n",
+		       nid, K(i.totalhigh),
+		       nid, K(i.freehigh),
+		       nid, K(i.totalram - i.totalhigh),
+		       nid, K(i.freeram - i.freehigh));
 #endif
+	n += sprintf(buf + n,
 		       "Node %d Dirty:          %8lu kB\n"
 		       "Node %d Writeback:      %8lu kB\n"
 		       "Node %d FilePages:      %8lu kB\n"
@@ -99,25 +118,6 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
 		       "Node %d Slab:           %8lu kB\n"
 		       "Node %d SReclaimable:   %8lu kB\n"
 		       "Node %d SUnreclaim:     %8lu kB\n",
-		       nid, K(i.totalram),
-		       nid, K(i.freeram),
-		       nid, K(i.totalram - i.freeram),
-		       nid, K(node_page_state(nid, NR_ACTIVE_ANON) +
-				node_page_state(nid, NR_ACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_INACTIVE_ANON) +
-				node_page_state(nid, NR_INACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_ACTIVE_ANON)),
-		       nid, K(node_page_state(nid, NR_INACTIVE_ANON)),
-		       nid, K(node_page_state(nid, NR_ACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_INACTIVE_FILE)),
-		       nid, K(node_page_state(nid, NR_UNEVICTABLE)),
-		       nid, K(node_page_state(nid, NR_MLOCK)),
-#ifdef CONFIG_HIGHMEM
-		       nid, K(i.totalhigh),
-		       nid, K(i.freehigh),
-		       nid, K(i.totalram - i.totalhigh),
-		       nid, K(i.freeram - i.freehigh),
-#endif
 		       nid, K(node_page_state(nid, NR_FILE_DIRTY)),
 		       nid, K(node_page_state(nid, NR_WRITEBACK)),
 		       nid, K(node_page_state(nid, NR_FILE_PAGES)),
-- 
1.6.5.2



--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] reduce stack usage of node_read_meminfo()
  2010-07-08  9:20 ` KOSAKI Motohiro
@ 2010-07-08 20:58   ` Andrew Morton
  -1 siblings, 0 replies; 10+ messages in thread
From: Andrew Morton @ 2010-07-08 20:58 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: LKML, linux-mm

On Thu,  8 Jul 2010 18:20:14 +0900 (JST)
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:

> 
> Now, cmpilation node_read_meminfo() output following warning. Because
> it has very large sprintf() argument.
> 
> 	drivers/base/node.c: In function 'node_read_meminfo':
> 	drivers/base/node.c:139: warning: the frame size of 848 bytes is
> 	larger than 512 bytes

hm, I'm surprised it's that much.

> --- a/drivers/base/node.c
> +++ b/drivers/base/node.c
> @@ -66,8 +66,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
>  	struct sysinfo i;
>  
>  	si_meminfo_node(&i, nid);
> -
> -	n = sprintf(buf, "\n"
> +	n = sprintf(buf,
>  		       "Node %d MemTotal:       %8lu kB\n"
>  		       "Node %d MemFree:        %8lu kB\n"
>  		       "Node %d MemUsed:        %8lu kB\n"
> @@ -78,13 +77,33 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
>  		       "Node %d Active(file):   %8lu kB\n"
>  		       "Node %d Inactive(file): %8lu kB\n"
>  		       "Node %d Unevictable:    %8lu kB\n"
> -		       "Node %d Mlocked:        %8lu kB\n"
> +		       "Node %d Mlocked:        %8lu kB\n",
> +		       nid, K(i.totalram),
> +		       nid, K(i.freeram),
> +		       nid, K(i.totalram - i.freeram),
> +		       nid, K(node_page_state(nid, NR_ACTIVE_ANON) +
> +				node_page_state(nid, NR_ACTIVE_FILE)),

Why the heck did we decide to print the same node-id 10000 times?

> +	n += sprintf(buf,

You just got caught sending untested patches.

--- a/drivers/base/node.c~drivers-base-nodec-reduce-stack-usage-of-node_read_meminfo-fix
+++ a/drivers/base/node.c
@@ -93,7 +93,7 @@ static ssize_t node_read_meminfo(struct 
 		       nid, K(node_page_state(nid, NR_MLOCK)));
 
 #ifdef CONFIG_HIGHMEM
-	n += sprintf(buf,
+	n += sprintf(buf + n,
 		       "Node %d HighTotal:      %8lu kB\n"
 		       "Node %d HighFree:       %8lu kB\n"
 		       "Node %d LowTotal:       %8lu kB\n"
@@ -103,7 +103,7 @@ static ssize_t node_read_meminfo(struct 
 		       nid, K(i.totalram - i.totalhigh),
 		       nid, K(i.freeram - i.freehigh));
 #endif
-	n += sprintf(buf,
+	n += sprintf(buf + n,
 		       "Node %d Dirty:          %8lu kB\n"
 		       "Node %d Writeback:      %8lu kB\n"
 		       "Node %d FilePages:      %8lu kB\n"
_


Please, run the code and check that we didn't muck up the output.

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

* Re: [PATCH] reduce stack usage of node_read_meminfo()
@ 2010-07-08 20:58   ` Andrew Morton
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Morton @ 2010-07-08 20:58 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: LKML, linux-mm

On Thu,  8 Jul 2010 18:20:14 +0900 (JST)
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:

> 
> Now, cmpilation node_read_meminfo() output following warning. Because
> it has very large sprintf() argument.
> 
> 	drivers/base/node.c: In function 'node_read_meminfo':
> 	drivers/base/node.c:139: warning: the frame size of 848 bytes is
> 	larger than 512 bytes

hm, I'm surprised it's that much.

> --- a/drivers/base/node.c
> +++ b/drivers/base/node.c
> @@ -66,8 +66,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
>  	struct sysinfo i;
>  
>  	si_meminfo_node(&i, nid);
> -
> -	n = sprintf(buf, "\n"
> +	n = sprintf(buf,
>  		       "Node %d MemTotal:       %8lu kB\n"
>  		       "Node %d MemFree:        %8lu kB\n"
>  		       "Node %d MemUsed:        %8lu kB\n"
> @@ -78,13 +77,33 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
>  		       "Node %d Active(file):   %8lu kB\n"
>  		       "Node %d Inactive(file): %8lu kB\n"
>  		       "Node %d Unevictable:    %8lu kB\n"
> -		       "Node %d Mlocked:        %8lu kB\n"
> +		       "Node %d Mlocked:        %8lu kB\n",
> +		       nid, K(i.totalram),
> +		       nid, K(i.freeram),
> +		       nid, K(i.totalram - i.freeram),
> +		       nid, K(node_page_state(nid, NR_ACTIVE_ANON) +
> +				node_page_state(nid, NR_ACTIVE_FILE)),

Why the heck did we decide to print the same node-id 10000 times?

> +	n += sprintf(buf,

You just got caught sending untested patches.

--- a/drivers/base/node.c~drivers-base-nodec-reduce-stack-usage-of-node_read_meminfo-fix
+++ a/drivers/base/node.c
@@ -93,7 +93,7 @@ static ssize_t node_read_meminfo(struct 
 		       nid, K(node_page_state(nid, NR_MLOCK)));
 
 #ifdef CONFIG_HIGHMEM
-	n += sprintf(buf,
+	n += sprintf(buf + n,
 		       "Node %d HighTotal:      %8lu kB\n"
 		       "Node %d HighFree:       %8lu kB\n"
 		       "Node %d LowTotal:       %8lu kB\n"
@@ -103,7 +103,7 @@ static ssize_t node_read_meminfo(struct 
 		       nid, K(i.totalram - i.totalhigh),
 		       nid, K(i.freeram - i.freehigh));
 #endif
-	n += sprintf(buf,
+	n += sprintf(buf + n,
 		       "Node %d Dirty:          %8lu kB\n"
 		       "Node %d Writeback:      %8lu kB\n"
 		       "Node %d FilePages:      %8lu kB\n"
_


Please, run the code and check that we didn't muck up the output.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] reduce stack usage of node_read_meminfo()
  2010-07-08 10:41   ` KOSAKI Motohiro
@ 2010-07-08 20:59     ` Andrew Morton
  -1 siblings, 0 replies; 10+ messages in thread
From: Andrew Morton @ 2010-07-08 20:59 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: LKML, linux-mm

On Thu,  8 Jul 2010 19:41:57 +0900 (JST)
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:

> Grr, I did sent old ver. right patch is here ;-)
> sorry.

oop, there it is.  Did you check the output carefully?

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

* Re: [PATCH] reduce stack usage of node_read_meminfo()
@ 2010-07-08 20:59     ` Andrew Morton
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Morton @ 2010-07-08 20:59 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: LKML, linux-mm

On Thu,  8 Jul 2010 19:41:57 +0900 (JST)
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:

> Grr, I did sent old ver. right patch is here ;-)
> sorry.

oop, there it is.  Did you check the output carefully?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] reduce stack usage of node_read_meminfo()
  2010-07-08 20:58   ` Andrew Morton
@ 2010-07-09  0:14     ` KOSAKI Motohiro
  -1 siblings, 0 replies; 10+ messages in thread
From: KOSAKI Motohiro @ 2010-07-09  0:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: kosaki.motohiro, LKML, linux-mm

> On Thu,  8 Jul 2010 18:20:14 +0900 (JST)
> KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> 
> > 
> > Now, cmpilation node_read_meminfo() output following warning. Because
> > it has very large sprintf() argument.
> > 
> > 	drivers/base/node.c: In function 'node_read_meminfo':
> > 	drivers/base/node.c:139: warning: the frame size of 848 bytes is
> > 	larger than 512 bytes
> 
> hm, I'm surprised it's that much.

me too.

> 
> > --- a/drivers/base/node.c
> > +++ b/drivers/base/node.c
> > @@ -66,8 +66,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
> >  	struct sysinfo i;
> >  
> >  	si_meminfo_node(&i, nid);
> > -
> > -	n = sprintf(buf, "\n"
> > +	n = sprintf(buf,
> >  		       "Node %d MemTotal:       %8lu kB\n"
> >  		       "Node %d MemFree:        %8lu kB\n"
> >  		       "Node %d MemUsed:        %8lu kB\n"
> > @@ -78,13 +77,33 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
> >  		       "Node %d Active(file):   %8lu kB\n"
> >  		       "Node %d Inactive(file): %8lu kB\n"
> >  		       "Node %d Unevictable:    %8lu kB\n"
> > -		       "Node %d Mlocked:        %8lu kB\n"
> > +		       "Node %d Mlocked:        %8lu kB\n",
> > +		       nid, K(i.totalram),
> > +		       nid, K(i.freeram),
> > +		       nid, K(i.totalram - i.freeram),
> > +		       nid, K(node_page_state(nid, NR_ACTIVE_ANON) +
> > +				node_page_state(nid, NR_ACTIVE_FILE)),
> 
> Why the heck did we decide to print the same node-id 10000 times?

dunno. but I don't want to make behavior change for only stack reducing.


> 
> > +	n += sprintf(buf,
> 
> You just got caught sending untested patches.
> 
> --- a/drivers/base/node.c~drivers-base-nodec-reduce-stack-usage-of-node_read_meminfo-fix
> +++ a/drivers/base/node.c
> @@ -93,7 +93,7 @@ static ssize_t node_read_meminfo(struct 
>  		       nid, K(node_page_state(nid, NR_MLOCK)));
>  
>  #ifdef CONFIG_HIGHMEM
> -	n += sprintf(buf,
> +	n += sprintf(buf + n,
>  		       "Node %d HighTotal:      %8lu kB\n"
>  		       "Node %d HighFree:       %8lu kB\n"
>  		       "Node %d LowTotal:       %8lu kB\n"
> @@ -103,7 +103,7 @@ static ssize_t node_read_meminfo(struct 
>  		       nid, K(i.totalram - i.totalhigh),
>  		       nid, K(i.freeram - i.freehigh));
>  #endif
> -	n += sprintf(buf,
> +	n += sprintf(buf + n,
>  		       "Node %d Dirty:          %8lu kB\n"
>  		       "Node %d Writeback:      %8lu kB\n"
>  		       "Node %d FilePages:      %8lu kB\n"
> _
> 
> 
> Please, run the code and check that we didn't muck up the output.

100% my fault. I ran it, but I forgot to merge two patches ;)





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

* Re: [PATCH] reduce stack usage of node_read_meminfo()
@ 2010-07-09  0:14     ` KOSAKI Motohiro
  0 siblings, 0 replies; 10+ messages in thread
From: KOSAKI Motohiro @ 2010-07-09  0:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: kosaki.motohiro, LKML, linux-mm

> On Thu,  8 Jul 2010 18:20:14 +0900 (JST)
> KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> 
> > 
> > Now, cmpilation node_read_meminfo() output following warning. Because
> > it has very large sprintf() argument.
> > 
> > 	drivers/base/node.c: In function 'node_read_meminfo':
> > 	drivers/base/node.c:139: warning: the frame size of 848 bytes is
> > 	larger than 512 bytes
> 
> hm, I'm surprised it's that much.

me too.

> 
> > --- a/drivers/base/node.c
> > +++ b/drivers/base/node.c
> > @@ -66,8 +66,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
> >  	struct sysinfo i;
> >  
> >  	si_meminfo_node(&i, nid);
> > -
> > -	n = sprintf(buf, "\n"
> > +	n = sprintf(buf,
> >  		       "Node %d MemTotal:       %8lu kB\n"
> >  		       "Node %d MemFree:        %8lu kB\n"
> >  		       "Node %d MemUsed:        %8lu kB\n"
> > @@ -78,13 +77,33 @@ static ssize_t node_read_meminfo(struct sys_device * dev,
> >  		       "Node %d Active(file):   %8lu kB\n"
> >  		       "Node %d Inactive(file): %8lu kB\n"
> >  		       "Node %d Unevictable:    %8lu kB\n"
> > -		       "Node %d Mlocked:        %8lu kB\n"
> > +		       "Node %d Mlocked:        %8lu kB\n",
> > +		       nid, K(i.totalram),
> > +		       nid, K(i.freeram),
> > +		       nid, K(i.totalram - i.freeram),
> > +		       nid, K(node_page_state(nid, NR_ACTIVE_ANON) +
> > +				node_page_state(nid, NR_ACTIVE_FILE)),
> 
> Why the heck did we decide to print the same node-id 10000 times?

dunno. but I don't want to make behavior change for only stack reducing.


> 
> > +	n += sprintf(buf,
> 
> You just got caught sending untested patches.
> 
> --- a/drivers/base/node.c~drivers-base-nodec-reduce-stack-usage-of-node_read_meminfo-fix
> +++ a/drivers/base/node.c
> @@ -93,7 +93,7 @@ static ssize_t node_read_meminfo(struct 
>  		       nid, K(node_page_state(nid, NR_MLOCK)));
>  
>  #ifdef CONFIG_HIGHMEM
> -	n += sprintf(buf,
> +	n += sprintf(buf + n,
>  		       "Node %d HighTotal:      %8lu kB\n"
>  		       "Node %d HighFree:       %8lu kB\n"
>  		       "Node %d LowTotal:       %8lu kB\n"
> @@ -103,7 +103,7 @@ static ssize_t node_read_meminfo(struct 
>  		       nid, K(i.totalram - i.totalhigh),
>  		       nid, K(i.freeram - i.freehigh));
>  #endif
> -	n += sprintf(buf,
> +	n += sprintf(buf + n,
>  		       "Node %d Dirty:          %8lu kB\n"
>  		       "Node %d Writeback:      %8lu kB\n"
>  		       "Node %d FilePages:      %8lu kB\n"
> _
> 
> 
> Please, run the code and check that we didn't muck up the output.

100% my fault. I ran it, but I forgot to merge two patches ;)




--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2010-07-09  0:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-08  9:20 [PATCH] reduce stack usage of node_read_meminfo() KOSAKI Motohiro
2010-07-08  9:20 ` KOSAKI Motohiro
2010-07-08 10:41 ` KOSAKI Motohiro
2010-07-08 10:41   ` KOSAKI Motohiro
2010-07-08 20:59   ` Andrew Morton
2010-07-08 20:59     ` Andrew Morton
2010-07-08 20:58 ` Andrew Morton
2010-07-08 20:58   ` Andrew Morton
2010-07-09  0:14   ` KOSAKI Motohiro
2010-07-09  0:14     ` KOSAKI Motohiro

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.