drivers/base/node.c: reduce stack usage of node_read_meminfo()
authorKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Tue, 10 Aug 2010 00:19:50 +0000 (17:19 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 10 Aug 2010 03:45:02 +0000 (20:45 -0700)
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

Fix it by splitting the sprintf() into three parts.  It has no functional
change.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/base/node.c

index 2bdd8a94ec944f8c98432ff3aed82529159378f1..2872e86837b2bb0013b1d2ea9b7d1095d17cd33c 100644 (file)
@@ -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)),