From: Andrew Morton <akpm@linux-foundation.org>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Christoph Lameter <cl@linux-foundation.org>,
linux-mm <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mempolicy: reduce stack size of migrate_pages()
Date: Fri, 18 Jun 2010 14:38:51 -0700 [thread overview]
Message-ID: <20100618143851.0661daa2.akpm@linux-foundation.org> (raw)
In-Reply-To: <20100616130040.3831.A69D9226@jp.fujitsu.com>
On Wed, 16 Jun 2010 13:36:57 +0900 (JST)
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
>
> Now, migrate_pages() are using >500 bytes stack. This patch reduce it.
>
> mm/mempolicy.c: In function 'sys_migrate_pages':
> mm/mempolicy.c:1344: warning: the frame size of 528 bytes is larger than
> 512 bytes
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> Cc: Christoph Lameter <cl@linux-foundation.org>
> ---
> mm/mempolicy.c | 35 ++++++++++++++++++++++-------------
> 1 files changed, 22 insertions(+), 13 deletions(-)
>
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 13b09bd..1116427 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -1275,33 +1275,39 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
> const unsigned long __user *, new_nodes)
> {
> const struct cred *cred = current_cred(), *tcred;
> - struct mm_struct *mm;
> + struct mm_struct *mm = NULL;
> struct task_struct *task;
> - nodemask_t old;
> - nodemask_t new;
> nodemask_t task_nodes;
> int err;
> + NODEMASK_SCRATCH(scratch);
> + nodemask_t *old = &scratch->mask1;
> + nodemask_t *new = &scratch->mask2;
>
> + if (!scratch)
> + return -ENOMEM;
It doesn't matter in practice, but it makes me all queazy to see code
which plays with pointers which might be NULL.
--- a/mm/mempolicy.c~mempolicy-reduce-stack-size-of-migrate_pages-fix
+++ a/mm/mempolicy.c
@@ -1279,13 +1279,16 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pi
struct task_struct *task;
nodemask_t task_nodes;
int err;
+ nodemask_t *old;
+ nodemask_t *new;
NODEMASK_SCRATCH(scratch);
- nodemask_t *old = &scratch->mask1;
- nodemask_t *new = &scratch->mask2;
if (!scratch)
return -ENOMEM;
+ old = &scratch->mask1;
+ new = &scratch->mask2;
+
err = get_nodes(old, old_nodes, maxnode);
if (err)
goto out;
_
--
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>
next prev parent reply other threads:[~2010-06-18 21:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-16 4:36 KOSAKI Motohiro
2010-06-16 4:56 ` KAMEZAWA Hiroyuki
2010-06-16 16:31 ` Christoph Lameter
2010-06-18 21:38 ` Andrew Morton [this message]
2010-06-21 11:45 ` KOSAKI Motohiro
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=20100618143851.0661daa2.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=cl@linux-foundation.org \
--cc=kosaki.motohiro@jp.fujitsu.com \
--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