sparsemem interaction with memory add bug fixes
Subsystems (2)
PATCH 1/1 sparsemem interaction with memory add bug fixes
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 <[email protected]> and Joel Schopp <[email protected]>.
mm/sparse.c +5 -2
@@ -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; }
Quoted 9 lines · Mike Kravetz
This patch fixes two bugs with the way sparsemem interacts with memory add. They are:
- memory leak if memmap for section already exists
- callingalloc_bootmem_node()after boot
These bugs were discovered and a first cut at the fixes were provided by Arnd Bergmann <[email protected]> and Joel Schopp <[email protected]>.Signed-off-by Mike Kravetz <[email protected]>
These fix memory adding spu addresses on cell, among other things.
Quoted 25 lines · Mike Kravetz
This patch fixes two bugs with the way sparsemem interacts with memory add. They are:
- memory leak if memmap for section already exists
- callingalloc_bootmem_node()after boot
These bugs were discovered and a first cut at the fixes were provided by Arnd Bergmann <[email protected]> and Joel Schopp <[email protected]>.Signed-off-by Mike Kravetz <[email protected]>diff -Naupr
linux-2.6.17-rc1-mm2/mm/sparse.clinux-2.6.17-rc1-mm2.work/mm/sparse.cmm/sparse.c +4
-1@@ -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);
mm/sparse.c int sparse_add_one_section(struct zone * · line 292
Quoted 10 lines
mm/sparse.c +1
-1@@ -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(-)
mm/sparse.c +2 -2
@@ -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; }
Quoted 55 lines · Andy Whitcroft
Quoted 25 lines · Mike Kravetz
This patch fixes two bugs with the way sparsemem interacts with memory add. They are:
- memory leak if memmap for section already exists
- callingalloc_bootmem_node()after boot
These bugs were discovered and a first cut at the fixes were provided by Arnd Bergmann <[email protected]> and Joel Schopp <[email protected]>.Signed-off-by Mike Kravetz <[email protected]>diff -Naupr
linux-2.6.17-rc1-mm2/mm/sparse.clinux-2.6.17-rc1-mm2.work/mm/sparse.cmm/sparse.c +4
-1@@ -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);mm/sparse.c int sparse_add_one_section(struct zone * · line 292
Quoted 10 lines
mm/sparse.c +1
-1@@ -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.ccurrent/mm/sparse.cmm/sparse.c +0
-0@@ -281,9 +281,9 @@ int sparse_add_one_section(struct zone *
mm/sparse.c int sparse_add_one_section(struct zone * · line 289
Quoted 10 lines
mm/sparse.c +2
-2ret =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
Quoted 6 lines · Mike Kravetz
This patch fixes two bugs with the way sparsemem interacts with memory add. They are:
- memory leak if memmap for section already exists
- callingalloc_bootmem_node()after boot
These bugs were discovered and a first cut at the fixes were provided by Arnd Bergmann <[email protected]> and Joel Schopp <[email protected]>.
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
Quoted 2 lines · Dave Hansen
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.
Signature · 1 line
Mike