[PATCH v4 3/9] mm/page_alloc: prevent creation of empty zones
From: Doug Berger
Date: Fri Mar 10 2023 - 19:40:05 EST
If none of the pages a zone spans are present then its start pfn
and span should be zeroed to prevent initialization.
This prevents the creation of an empty zone if all of its pages
are moved to a zone that would overlap it.
The real_size name is reverted to just size to reduce the burden
of supporting multiple realities.
Signed-off-by: Doug Berger <opendmb@xxxxxxxxx>
---
mm/page_alloc.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b1952f86ab6d..827b4bfef625 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7592,8 +7592,7 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
for (i = 0; i < MAX_NR_ZONES; i++) {
struct zone *zone = pgdat->node_zones + i;
unsigned long zone_start_pfn, zone_end_pfn;
- unsigned long spanned, absent;
- unsigned long size, real_size;
+ unsigned long spanned, absent, size;
spanned = zone_spanned_pages_in_node(pgdat->node_id, i,
node_start_pfn,
@@ -7604,20 +7603,21 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
node_start_pfn,
node_end_pfn);
- size = spanned;
- real_size = size - absent;
+ size = spanned - absent;
- if (size)
+ if (size) {
zone->zone_start_pfn = zone_start_pfn;
- else
+ } else {
+ spanned = 0;
zone->zone_start_pfn = 0;
- zone->spanned_pages = size;
- zone->present_pages = real_size;
+ }
+ zone->spanned_pages = spanned;
+ zone->present_pages = size;
#if defined(CONFIG_MEMORY_HOTPLUG)
- zone->present_early_pages = real_size;
+ zone->present_early_pages = size;
#endif
- totalpages += real_size;
+ totalpages += size;
}
pgdat->node_spanned_pages = node_end_pfn - node_start_pfn;
--
2.34.1