diff options
author | Johannes Weiner <hannes@saeurebad.de> | 2008-07-24 00:28:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-24 13:47:20 -0400 |
commit | 75a56cfe9fdb064d1db1cfbc564315fddb756fb1 (patch) | |
tree | 4b72b655e1137792a3213678416bf0541e7a3b1b /mm/bootmem.c | |
parent | 4cc278b721d5bf3569dfc5f1100253042e097bc3 (diff) |
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>
Diffstat (limited to 'mm/bootmem.c')
-rw-r--r-- | mm/bootmem.c | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/mm/bootmem.c b/mm/bootmem.c index 459da4710b8f..282b786c2b15 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c | |||
@@ -632,30 +632,15 @@ void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size, | |||
632 | void * __init alloc_bootmem_section(unsigned long size, | 632 | void * __init alloc_bootmem_section(unsigned long size, |
633 | unsigned long section_nr) | 633 | unsigned long section_nr) |
634 | { | 634 | { |
635 | void *ptr; | 635 | bootmem_data_t *bdata; |
636 | unsigned long limit, goal, start_nr, end_nr, pfn; | 636 | unsigned long pfn, goal, limit; |
637 | struct pglist_data *pgdat; | ||
638 | 637 | ||
639 | pfn = section_nr_to_pfn(section_nr); | 638 | pfn = section_nr_to_pfn(section_nr); |
640 | goal = PFN_PHYS(pfn); | 639 | goal = pfn << PAGE_SHIFT; |
641 | limit = PFN_PHYS(section_nr_to_pfn(section_nr + 1)) - 1; | 640 | limit = section_nr_to_pfn(section_nr + 1) << PAGE_SHIFT; |
642 | pgdat = NODE_DATA(early_pfn_to_nid(pfn)); | 641 | bdata = &bootmem_node_data[early_pfn_to_nid(pfn)]; |
643 | ptr = alloc_bootmem_core(pgdat->bdata, size, SMP_CACHE_BYTES, goal, | ||
644 | limit); | ||
645 | |||
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 | 642 | ||
658 | return ptr; | 643 | return alloc_bootmem_core(bdata, size, SMP_CACHE_BYTES, goal, limit); |
659 | } | 644 | } |
660 | #endif | 645 | #endif |
661 | 646 | ||