Commit 238305bb4d418c95977162ba13c11880685fc731

Authored by Johannes Weiner
Committed by Linus Torvalds
1 parent e9079911e6

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>

Showing 4 changed files with 12 additions and 60 deletions Side-by-side Diff

include/linux/bootmem.h
... ... @@ -135,9 +135,6 @@
135 135 extern int reserve_bootmem_generic(unsigned long addr, unsigned long size,
136 136 int flags);
137 137  
138   -extern void *alloc_bootmem_section(unsigned long size,
139   - unsigned long section_nr);
140   -
141 138 #ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP
142 139 extern void *alloc_remap(int nid, unsigned long size);
143 140 #else
... ... @@ -803,28 +803,6 @@
803 803  
804 804 }
805 805  
806   -#ifdef CONFIG_SPARSEMEM
807   -/**
808   - * alloc_bootmem_section - allocate boot memory from a specific section
809   - * @size: size of the request in bytes
810   - * @section_nr: sparse map section to allocate from
811   - *
812   - * Return NULL on failure.
813   - */
814   -void * __init alloc_bootmem_section(unsigned long size,
815   - unsigned long section_nr)
816   -{
817   - bootmem_data_t *bdata;
818   - unsigned long pfn, goal;
819   -
820   - pfn = section_nr_to_pfn(section_nr);
821   - goal = pfn << PAGE_SHIFT;
822   - bdata = &bootmem_node_data[early_pfn_to_nid(pfn)];
823   -
824   - return alloc_bootmem_bdata(bdata, size, SMP_CACHE_BYTES, goal, 0);
825   -}
826   -#endif
827   -
828 806 #ifndef ARCH_LOW_ADDRESS_LIMIT
829 807 #define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL
830 808 #endif
... ... @@ -355,28 +355,6 @@
355 355 return __alloc_bootmem_node(pgdat, size, align, goal);
356 356 }
357 357  
358   -#ifdef CONFIG_SPARSEMEM
359   -/**
360   - * alloc_bootmem_section - allocate boot memory from a specific section
361   - * @size: size of the request in bytes
362   - * @section_nr: sparse map section to allocate from
363   - *
364   - * Return NULL on failure.
365   - */
366   -void * __init alloc_bootmem_section(unsigned long size,
367   - unsigned long section_nr)
368   -{
369   - unsigned long pfn, goal, limit;
370   -
371   - pfn = section_nr_to_pfn(section_nr);
372   - goal = pfn << PAGE_SHIFT;
373   - limit = section_nr_to_pfn(section_nr + 1) << PAGE_SHIFT;
374   -
375   - return __alloc_memory_core_early(early_pfn_to_nid(pfn), size,
376   - SMP_CACHE_BYTES, goal, limit);
377   -}
378   -#endif
379   -
380 358 #ifndef ARCH_LOW_ADDRESS_LIMIT
381 359 #define ARCH_LOW_ADDRESS_LIMIT 0xffffffffUL
382 360 #endif
... ... @@ -273,10 +273,10 @@
273 273 #ifdef CONFIG_MEMORY_HOTREMOVE
274 274 static unsigned long * __init
275 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;
279   -
  278 + pg_data_t *host_pgdat;
  279 + unsigned long goal;
280 280 /*
281 281 * A page may contain usemaps for other sections preventing the
282 282 * page being freed and making a section unremovable while
... ... @@ -287,8 +287,10 @@
287 287 * from the same section as the pgdat where possible to avoid
288 288 * this problem.
289 289 */
290   - section_nr = pfn_to_section_nr(__pa(pgdat) >> PAGE_SHIFT);
291   - return alloc_bootmem_section(usemap_size() * count, section_nr);
  290 + goal = __pa(pgdat) & PAGE_SECTION_MASK;
  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 296 static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
295 297  
... ... @@ -332,9 +334,9 @@
332 334 #else
333 335 static unsigned long * __init
334 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 342 static void __init check_usemap_section_nr(int nid, unsigned long *usemap)
341 343  
... ... @@ -352,13 +354,10 @@
352 354 int size = usemap_size();
353 355  
354 356 usemap = sparse_early_usemaps_alloc_pgdat_section(NODE_DATA(nodeid),
355   - usemap_count);
  357 + size * usemap_count);
356 358 if (!usemap) {
357   - usemap = alloc_bootmem_node(NODE_DATA(nodeid), size * usemap_count);
358   - if (!usemap) {
359   - printk(KERN_WARNING "%s: allocation failed\n", __func__);
360   - return;
361   - }
  359 + printk(KERN_WARNING "%s: allocation failed\n", __func__);
  360 + return;
362 361 }
363 362  
364 363 for (pnum = pnum_begin; pnum < pnum_end; pnum++) {