diff options
Diffstat (limited to 'mm/nobootmem.c')
-rw-r--r-- | mm/nobootmem.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/mm/nobootmem.c b/mm/nobootmem.c index 2c254d3..61107cf 100644 --- a/mm/nobootmem.c +++ b/mm/nobootmem.c @@ -82,18 +82,27 @@ void __init free_bootmem_late(unsigned long addr, unsigned long size) static void __init __free_pages_memory(unsigned long start, unsigned long end) { - int order; + unsigned long i, start_aligned, end_aligned; + int order = ilog2(BITS_PER_LONG); - while (start < end) { - order = min(MAX_ORDER - 1UL, __ffs(start)); + start_aligned = (start + (BITS_PER_LONG - 1)) & ~(BITS_PER_LONG - 1); + end_aligned = end & ~(BITS_PER_LONG - 1); - while (start + (1UL << order) > end) - order--; + if (end_aligned <= start_aligned) { + for (i = start; i < end; i++) + __free_pages_bootmem(pfn_to_page(i), 0); - __free_pages_bootmem(pfn_to_page(start), order); - - start += (1UL << order); + return; } + + for (i = start; i < start_aligned; i++) + __free_pages_bootmem(pfn_to_page(i), 0); + + for (i = start_aligned; i < end_aligned; i += BITS_PER_LONG) + __free_pages_bootmem(pfn_to_page(i), order); + + for (i = end_aligned; i < end; i++) + __free_pages_bootmem(pfn_to_page(i), 0); } static unsigned long __init __free_memory_core(phys_addr_t start, |