@@ -6936,11 +6936,19 @@ void __init free_area_init_memoryless_node(int nid)
*/
static u64 __init init_unavailable_range(unsigned long spfn, unsigned long epfn)
{
- unsigned long pfn;
+ unsigned long pfn, block_pfn;
u64 pgcnt = 0;
+ bool in_block = 0;
+
+ block_pfn = ALIGN_DOWN(spfn, pageblock_nr_pages);
for (pfn = spfn; pfn < epfn; pfn++) {
- if (!pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) {
+ if (block_pfn != ALIGN_DOWN(pfn, pageblock_nr_pages)) {
+ block_pfn = ALIGN_DOWN(pfn, pageblock_nr_pages);
+ in_block = 0;
+ }
+
+ if (!in_block && !pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) {
pfn = ALIGN_DOWN(pfn, pageblock_nr_pages)
+ pageblock_nr_pages - 1;
continue;
@@ -6953,6 +6961,7 @@ static u64 __init init_unavailable_range(unsigned long spfn, unsigned long epfn)
__init_single_page(pfn_to_page(pfn), pfn, 0, 0);
__SetPageReserved(pfn_to_page(pfn));
pgcnt++;
+ in_block = 1;
}
return pgcnt;