linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] mm/mm_init.c: account absent_page only if spanned_page is non-zero
@ 2023-05-25  4:01 Haifeng Xu
  0 siblings, 0 replies; only message in thread
From: Haifeng Xu @ 2023-05-25  4:01 UTC (permalink / raw)
  To: akpm; +Cc: mhocko, david, linux-mm, linux-kernel, Haifeng Xu

If spanned_page is zero, it's pointless to calculate the number of
absent_page. Also, the real size can be assigned to zero directly.

Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
---
 mm/mm_init.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index cf55bba04b23..898af4eb9ce2 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1260,31 +1260,30 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
 		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 real_size;
 
 		spanned = zone_spanned_pages_in_node(pgdat->node_id, i,
 						     node_start_pfn,
 						     node_end_pfn,
 						     &zone_start_pfn,
 						     &zone_end_pfn);
-		absent = zone_absent_pages_in_node(pgdat->node_id, i,
-						   node_start_pfn,
-						   node_end_pfn);
-
-		size = spanned;
-		real_size = size - absent;
-
-		if (size)
+		if (spanned) {
+			absent = zone_absent_pages_in_node(pgdat->node_id, i,
+							   node_start_pfn,
+							   node_end_pfn);
+			real_size = spanned - absent;
 			zone->zone_start_pfn = zone_start_pfn;
-		else
+		} else {
+			real_size = 0;
 			zone->zone_start_pfn = 0;
-		zone->spanned_pages = size;
+		}
+		zone->spanned_pages = spanned;
 		zone->present_pages = real_size;
 #if defined(CONFIG_MEMORY_HOTPLUG)
 		zone->present_early_pages = real_size;
 #endif
 
-		totalpages += size;
+		totalpages += spanned;
 		realtotalpages += real_size;
 	}
 
-- 
2.25.1



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-25  4:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-25  4:01 [PATCH 2/3] mm/mm_init.c: account absent_page only if spanned_page is non-zero Haifeng Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox