From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: kosaki.motohiro@jp.fujitsu.com,
LKML <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>
Subject: Re: [PATCH] reduce stack usage of node_read_meminfo()
Date: Fri, 9 Jul 2010 09:14:31 +0900 (JST) [thread overview]
Message-ID: <20100709091138.CD57.A69D9226@jp.fujitsu.com> (raw)
In-Reply-To: <20100708135805.b4411965.akpm@linux-foundation.org>
> 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>
prev parent reply other threads:[~2010-07-09 0:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-08 9:20 KOSAKI Motohiro
2010-07-08 10:41 ` KOSAKI Motohiro
2010-07-08 20:59 ` Andrew Morton
2010-07-08 20:58 ` Andrew Morton
2010-07-09 0:14 ` KOSAKI Motohiro [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100709091138.CD57.A69D9226@jp.fujitsu.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox