free_area_init_node() calls calculate_node_totalpages() and free_area_init_core(). The former to get node's {spanned,present}_pages, and the latter to calculate, among other things, how many pages per zone we spent on memmap_pages, which is used to substract zone's free pages. On memoryless-nodes, it is pointless to perform such a bunch of work, so make sure we skip the calculations when having a node or empty zone. Signed-off-by: Oscar Salvador <osalvador@xxxxxxx> --- mm/page_alloc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e008a3df0485..2b9b2422ba32 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7361,6 +7361,10 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, unsigned long realtotalpages = 0, totalpages = 0; enum zone_type i; + /* Skip calculation for memoryless nodes */ + if (pgdat_is_empty(pgdat)) + goto no_pages; + for (i = 0; i < MAX_NR_ZONES; i++) { struct zone *zone = pgdat->node_zones + i; unsigned long zone_start_pfn, zone_end_pfn; @@ -7393,6 +7397,7 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, realtotalpages += real_size; } +no_pages: pgdat->node_spanned_pages = totalpages; pgdat->node_present_pages = realtotalpages; pr_debug("On node %d totalpages: %lu\n", pgdat->node_id, realtotalpages); @@ -7610,6 +7615,12 @@ static void __init free_area_init_core(struct pglist_data *pgdat) size = zone->spanned_pages; freesize = zone->present_pages; + /* No pages? Nothing to calculate then. */ + if (!size) { + zone_init_internals(zone, j, nid, 0); + continue; + } + /* * Adjust freesize so that it accounts for how much memory * is used by this zone for memmap. This affects the watermark @@ -7647,9 +7658,6 @@ static void __init free_area_init_core(struct pglist_data *pgdat) */ zone_init_internals(zone, j, nid, freesize); - if (!size) - continue; - set_pageblock_order(); setup_usemap(zone); init_currently_empty_zone(zone, zone->zone_start_pfn, size); @@ -7730,7 +7738,7 @@ static void __init free_area_init_node(int nid) pgdat->node_start_pfn = start_pfn; pgdat->per_cpu_nodestats = NULL; - if (start_pfn != end_pfn) { + if (!pgdat_is_empty(pgdat)) { pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid, (u64)start_pfn << PAGE_SHIFT, end_pfn ? ((u64)end_pfn << PAGE_SHIFT) - 1 : 0); -- 2.35.3