Re: [PATCH] mempolicy: reduce stack size of migrate_pages()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 16 Jun 2010 13:36:57 +0900 (JST)
KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxx>
> Cc: Christoph Lameter <cl@xxxxxxxxxxxxxxxxxxxx>
> ---
>  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@xxxxxxxxxx  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]