* [PATCH] sparsemem interaction with memory add bug fixes
@ 2006-04-12 2:33 Mike Kravetz
2006-04-12 9:32 ` [Lhms-devel] " jschopp
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Mike Kravetz @ 2006-04-12 2:33 UTC (permalink / raw)
To: Andrew Morton
Cc: Arnd Bergmann, Joel H Schopp, Dave Hansen, Andy Whitcroft,
lhms-devel, linux-kernel
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;
}
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [Lhms-devel] [PATCH] sparsemem interaction with memory add bug fixes 2006-04-12 2:33 [PATCH] sparsemem interaction with memory add bug fixes Mike Kravetz @ 2006-04-12 9:32 ` jschopp 2006-04-12 13:22 ` Andy Whitcroft 2006-04-12 14:46 ` Dave Hansen 2 siblings, 0 replies; 6+ messages in thread From: jschopp @ 2006-04-12 9:32 UTC (permalink / raw) To: Mike Kravetz Cc: Andrew Morton, Arnd Bergmann, Joel H Schopp, Dave Hansen, Andy Whitcroft, lhms-devel, linux-kernel 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> > These fix memory adding spu addresses on cell, among other things. Signed-off-by: Joel Schopp <jschopp@austin.ibm.com> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sparsemem interaction with memory add bug fixes 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 2006-04-12 13:43 ` jschopp 2006-04-12 14:46 ` Dave Hansen 2 siblings, 1 reply; 6+ messages in thread From: Andy Whitcroft @ 2006-04-12 13:22 UTC (permalink / raw) To: Mike Kravetz Cc: Andrew Morton, Arnd Bergmann, Joel H Schopp, Dave Hansen, lhms-devel, linux-kernel [-- 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; } ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sparsemem interaction with memory add bug fixes 2006-04-12 13:22 ` Andy Whitcroft @ 2006-04-12 13:43 ` jschopp 0 siblings, 0 replies; 6+ messages in thread From: jschopp @ 2006-04-12 13:43 UTC (permalink / raw) To: Andy Whitcroft Cc: Mike Kravetz, Andrew Morton, Arnd Bergmann, Joel H Schopp, haveblue, lhms-devel, linux-kernel Andy Whitcroft wrote: > 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 > > > > ------------------------------------------------------------------------ > > 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; > } Whatever, I don't really care. It doesn't matter functionally if we free under the pgdat_resize lock or not. This looks fine, as does the original patch. If resizing pgdats was a hot path we might prefer this way outside the lock. -Joel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sparsemem interaction with memory add bug fixes 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 @ 2006-04-12 14:46 ` Dave Hansen 2006-04-12 16:05 ` [Lhms-devel] " Mike Kravetz 2 siblings, 1 reply; 6+ messages in thread From: Dave Hansen @ 2006-04-12 14:46 UTC (permalink / raw) To: Mike Kravetz Cc: Andrew Morton, Arnd Bergmann, Joel H Schopp, Andy Whitcroft, lhms-devel, linux-kernel On Tue, 2006-04-11 at 19:33 -0700, 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>. At first glance, these seem fine to me. Just out of curiosity. Can these issues be revealed with current code, or do they only show up with the cell changes? -- Dave ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Lhms-devel] Re: [PATCH] sparsemem interaction with memory add bug fixes 2006-04-12 14:46 ` Dave Hansen @ 2006-04-12 16:05 ` Mike Kravetz 0 siblings, 0 replies; 6+ messages in thread From: Mike Kravetz @ 2006-04-12 16:05 UTC (permalink / raw) To: Dave Hansen Cc: Mike Kravetz, Andrew Morton, Arnd Bergmann, Joel H Schopp, Andy Whitcroft, lhms-devel, linux-kernel On Wed, Apr 12, 2006 at 07:46:04AM -0700, Dave Hansen wrote: > Just out of curiosity. Can these issues be revealed with current code, > or do they only show up with the cell changes? Yes, you could hit either of these doing memory adds with the current code. The follow up issue of adding sub-section amounts of memory is cell specific. -- Mike ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-04-12 16:05 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2006-04-12 13:43 ` jschopp 2006-04-12 14:46 ` Dave Hansen 2006-04-12 16:05 ` [Lhms-devel] " Mike Kravetz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox