diff options
| author | Yinghai Lu <yinghai@kernel.org> | 2012-07-11 14:02:53 -0700 |
|---|---|---|
| committer | doc HD <doc.divxm@gmail.com> | 2015-12-21 12:23:26 +0100 |
| commit | dcda2072abbb42a7c5a606728e337e2ac0264243 (patch) | |
| tree | 2f5f681b2b9e78629a8d9dc3ca9cbc6b5ef49e83 | |
| parent | 04a941a809de6e32e38ed6c108989fddfe4d4ac4 (diff) | |
mm: sparse: fix usemap allocation above node descriptor sectionlp5.1
commit 99ab7b19440a72ebdf225f99b20f8ef40decee86 upstream.
After commit f5bf18fa22f8 ("bootmem/sparsemem: remove limit constraint
in alloc_bootmem_section"), usemap allocations may easily be placed
outside the optimal section that holds the node descriptor, even if
there is space available in that section. This results in unnecessary
hotplug dependencies that need to have the node unplugged before the
section holding the usemap.
The reason is that the bootmem allocator doesn't guarantee a linear
search starting from the passed allocation goal but may start out at a
much higher address absent an upper limit.
Fix this by trying the allocation with the limit at the section end,
then retry without if that fails. This keeps the fix from f5bf18fa22f8
of not panicking if the allocation does not fit in the section, but
still makes sure to try to stay within the section at first.
[rewritten massively by Johannes to apply to 3.4]
Change-Id: Ie40e51558b3abcaf0c0e72846928b84fe17f055a
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | mm/bootmem.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/mm/bootmem.c b/mm/bootmem.c index 3db582005e8..c4804c94afb 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c @@ -766,13 +766,17 @@ void * __init alloc_bootmem_section(unsigned long size, unsigned long section_nr) { bootmem_data_t *bdata; - unsigned long pfn, goal; + unsigned long pfn, goal, limit; pfn = section_nr_to_pfn(section_nr); goal = pfn << PAGE_SHIFT; + limit = section_nr_to_pfn(section_nr + 1) << PAGE_SHIFT; bdata = &bootmem_node_data[early_pfn_to_nid(pfn)]; - return alloc_bootmem_core(bdata, size, SMP_CACHE_BYTES, goal, 0); + if (goal + size > limit) + limit = 0; + + return alloc_bootmem_core(bdata, size, SMP_CACHE_BYTES, goal, limit); } #endif |
