diff options
author | Johannes Weiner <hannes@cmpxchg.org> | 2012-05-29 18:06:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-29 19:22:22 -0400 |
commit | 238305bb4d418c95977162ba13c11880685fc731 (patch) | |
tree | 43f578a711e85af44b1b1b43e8f32ef86490486f /mm/sparse.c | |
parent | e9079911e6c8fb7882de142de76f3ee49b54e000 (diff) |
mm: remove sparsemem allocation details from the bootmem allocator
alloc_bootmem_section() derives allocation area constraints from the
specified sparsemem section. This is a bit specific for a generic memory
allocator like bootmem, though, so move it over to sparsemem.
As __alloc_bootmem_node_nopanic() already retries failed allocations with
relaxed area constraints, the fallback code in sparsemem.c can be removed
and the code becomes a bit more compact overall.
[akpm@linux-foundation.org: fix build]
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: David S. Miller <davem@davemloft.net>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/sparse.c')
-rw-r--r-- | mm/sparse.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/mm/sparse.c b/mm/sparse.c index a8bc7d364deb..6a4bf9160e85 100644 --- a/mm/sparse.c +++ b/mm/sparse.c | |||
@@ -273,10 +273,10 @@ static unsigned long *__kmalloc_section_usemap(void) | |||
273 | #ifdef CONFIG_MEMORY_HOTREMOVE | 273 | #ifdef CONFIG_MEMORY_HOTREMOVE |
274 | static unsigned long * __init | 274 | static unsigned long * __init |
275 | sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, | 275 | sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, |
276 | unsigned long count) | 276 | unsigned long size) |
277 | { | 277 | { |
278 | unsigned long section_nr; | 278 | pg_data_t *host_pgdat; |
279 | 279 | unsigned long goal; | |
280 | /* | 280 | /* |
281 | * A page may contain usemaps for other sections preventing the | 281 | * A page may contain usemaps for other sections preventing the |
282 | * page being freed and making a section unremovable while | 282 | * page being freed and making a section unremovable while |
@@ -287,8 +287,10 @@ sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, | |||
287 | * from the same section as the pgdat where possible to avoid | 287 | * from the same section as the pgdat where possible to avoid |
288 | * this problem. | 288 | * this problem. |
289 | */ | 289 | */ |
290 | section_nr = pfn_to_section_nr(__pa(pgdat) >> PAGE_SHIFT); | 290 | goal = __pa(pgdat) & PAGE_SECTION_MASK; |
291 | return alloc_bootmem_section(usemap_size() * count, section_nr); | 291 | host_pgdat = NODE_DATA(early_pfn_to_nid(goal >> PAGE_SHIFT)); |
292 | return __alloc_bootmem_node_nopanic(host_pgdat, size, | ||
293 | SMP_CACHE_BYTES, goal); | ||
292 | } | 294 | } |
293 | 295 | ||
294 | static void __init check_usemap_section_nr(int nid, unsigned long *usemap) | 296 | static void __init check_usemap_section_nr(int nid, unsigned long *usemap) |
@@ -332,9 +334,9 @@ static void __init check_usemap_section_nr(int nid, unsigned long *usemap) | |||
332 | #else | 334 | #else |
333 | static unsigned long * __init | 335 | static unsigned long * __init |
334 | sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, | 336 | sparse_early_usemaps_alloc_pgdat_section(struct pglist_data *pgdat, |
335 | unsigned long count) | 337 | unsigned long size) |
336 | { | 338 | { |
337 | return NULL; | 339 | return alloc_bootmem_node_nopanic(pgdat, size); |
338 | } | 340 | } |
339 | 341 | ||
340 | static void __init check_usemap_section_nr(int nid, unsigned long *usemap) | 342 | static void __init check_usemap_section_nr(int nid, unsigned long *usemap) |
@@ -352,13 +354,10 @@ static void __init sparse_early_usemaps_alloc_node(unsigned long**usemap_map, | |||
352 | int size = usemap_size(); | 354 | int size = usemap_size(); |
353 | 355 | ||
354 | usemap = sparse_early_usemaps_alloc_pgdat_section(NODE_DATA(nodeid), | 356 | usemap = sparse_early_usemaps_alloc_pgdat_section(NODE_DATA(nodeid), |
355 | usemap_count); | 357 | size * usemap_count); |
356 | if (!usemap) { | 358 | if (!usemap) { |
357 | usemap = alloc_bootmem_node(NODE_DATA(nodeid), size * usemap_count); | 359 | printk(KERN_WARNING "%s: allocation failed\n", __func__); |
358 | if (!usemap) { | 360 | return; |
359 | printk(KERN_WARNING "%s: allocation failed\n", __func__); | ||
360 | return; | ||
361 | } | ||
362 | } | 361 | } |
363 | 362 | ||
364 | for (pnum = pnum_begin; pnum < pnum_end; pnum++) { | 363 | for (pnum = pnum_begin; pnum < pnum_end; pnum++) { |