public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Whitcroft <apw@shadowen.org>
To: Mike Kravetz <mjkravetz@verizon.net>
Cc: Andrew Morton <akpm@osdl.org>, Arnd Bergmann <arnd@arndb.de>,
	Joel H Schopp <jschopp@us.ibm.com>,
	Dave Hansen <haveblue@us.ibm.com>,
	lhms-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sparsemem interaction with memory add bug fixes
Date: Wed, 12 Apr 2006 14:22:56 +0100	[thread overview]
Message-ID: <443CFF30.1090801@shadowen.org> (raw)
In-Reply-To: <20060412023347.GA9343@w-mikek2.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 1602 bytes --]

Mike Kravetz wrote:
> This patch fixes two bugs with the way sparsemem interacts with memory
> add.  They are:
> - memory leak if memmap for section already exists
> - calling alloc_bootmem_node() after boot
> These bugs were discovered and a first cut at the fixes were provided by
> Arnd Bergmann <arnd@arndb.de> and Joel Schopp <jschopp@us.ibm.com>.
> 
> Signed-off-by: Mike Kravetz <kravetz@us.ibm.com>
> 
> diff -Naupr linux-2.6.17-rc1-mm2/mm/sparse.c linux-2.6.17-rc1-mm2.work/mm/sparse.c
> --- linux-2.6.17-rc1-mm2/mm/sparse.c	2006-04-03 03:22:10.000000000 +0000
> +++ linux-2.6.17-rc1-mm2.work/mm/sparse.c	2006-04-11 23:32:10.000000000 +0000
> @@ -32,7 +32,10 @@ static struct mem_section *sparse_index_
>  	unsigned long array_size = SECTIONS_PER_ROOT *
>  				   sizeof(struct mem_section);
>  
> -	section = alloc_bootmem_node(NODE_DATA(nid), array_size);
> +	if (system_state == SYSTEM_RUNNING)
> +		section = kmalloc_node(array_size, GFP_KERNEL, nid);
> +	else
> +		section = alloc_bootmem_node(NODE_DATA(nid), array_size);
>  
>  	if (section)
>  		memset(section, 0, array_size);
> @@ -281,9 +284,9 @@ int sparse_add_one_section(struct zone *
>  
>  	ret = sparse_init_one_section(ms, section_nr, memmap);
>  
> +out:
>  	if (ret <= 0)
>  		__kfree_section_memmap(memmap, nr_pages);
> -out:
>  	pgdat_resize_unlock(pgdat, &flags);
>  	return ret;
>  }

First change looks sane.  For the second it makes it obvious that we are
freeing the alloc'd section within the pgdat resize lock.  Doesn't seem
to make any sense to do that to me?  Perhaps it should be more like the
attached.

-apw


[-- Attachment #2: fix-leak-in-sparse_add_one_section --]
[-- Type: text/plain, Size: 479 bytes --]

 sparse.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff -upN reference/mm/sparse.c current/mm/sparse.c
--- reference/mm/sparse.c
+++ current/mm/sparse.c
@@ -281,9 +281,9 @@ int sparse_add_one_section(struct zone *
 
 	ret = sparse_init_one_section(ms, section_nr, memmap);
 
-	if (ret <= 0)
-		__kfree_section_memmap(memmap, nr_pages);
 out:
 	pgdat_resize_unlock(pgdat, &flags);
+	if (ret <= 0)
+		__kfree_section_memmap(memmap, nr_pages);
 	return ret;
 }

  parent reply	other threads:[~2006-04-12 13:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-12  2:33 [PATCH] sparsemem interaction with memory add bug fixes Mike Kravetz
2006-04-12  9:32 ` [Lhms-devel] " jschopp
2006-04-12 13:22 ` Andy Whitcroft [this message]
2006-04-12 13:43   ` jschopp
2006-04-12 14:46 ` Dave Hansen
2006-04-12 16:05   ` [Lhms-devel] " Mike Kravetz
  -- strict thread matches above, loose matches on Subject: below --
2006-04-12 17:19 Mike Kravetz

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=443CFF30.1090801@shadowen.org \
    --to=apw@shadowen.org \
    --cc=akpm@osdl.org \
    --cc=arnd@arndb.de \
    --cc=haveblue@us.ibm.com \
    --cc=jschopp@us.ibm.com \
    --cc=lhms-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjkravetz@verizon.net \
    /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