Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bootmem: revisit alloc_bootmem_section

Since alloc_bootmem_core does no goal-fallback anymore and just returns
NULL if the allocation fails, we might now use it in alloc_bootmem_section
without all the fixup code for a misplaced allocation.

Also, the limit can be the first PFN of the next section as the semantics
is that the limit is _above_ the allocated region, not within.

Signed-off-by: Johannes Weiner <hannes@saeurebad.de>
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Johannes Weiner and committed by
Linus Torvalds
75a56cfe 4cc278b7

+6 -21
+6 -21
mm/bootmem.c
··· 632 632 void * __init alloc_bootmem_section(unsigned long size, 633 633 unsigned long section_nr) 634 634 { 635 - void *ptr; 636 - unsigned long limit, goal, start_nr, end_nr, pfn; 637 - struct pglist_data *pgdat; 635 + bootmem_data_t *bdata; 636 + unsigned long pfn, goal, limit; 638 637 639 638 pfn = section_nr_to_pfn(section_nr); 640 - goal = PFN_PHYS(pfn); 641 - limit = PFN_PHYS(section_nr_to_pfn(section_nr + 1)) - 1; 642 - pgdat = NODE_DATA(early_pfn_to_nid(pfn)); 643 - ptr = alloc_bootmem_core(pgdat->bdata, size, SMP_CACHE_BYTES, goal, 644 - limit); 639 + goal = pfn << PAGE_SHIFT; 640 + limit = section_nr_to_pfn(section_nr + 1) << PAGE_SHIFT; 641 + bdata = &bootmem_node_data[early_pfn_to_nid(pfn)]; 645 642 646 - if (!ptr) 647 - return NULL; 648 - 649 - start_nr = pfn_to_section_nr(PFN_DOWN(__pa(ptr))); 650 - end_nr = pfn_to_section_nr(PFN_DOWN(__pa(ptr) + size)); 651 - if (start_nr != section_nr || end_nr != section_nr) { 652 - printk(KERN_WARNING "alloc_bootmem failed on section %ld.\n", 653 - section_nr); 654 - free_bootmem_node(pgdat, __pa(ptr), size); 655 - ptr = NULL; 656 - } 657 - 658 - return ptr; 643 + return alloc_bootmem_core(bdata, size, SMP_CACHE_BYTES, goal, limit); 659 644 } 660 645 #endif 661 646