[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230525040150.1588-3-haifeng.xu@shopee.com>
Date: Thu, 25 May 2023 04:01:50 +0000
From: Haifeng Xu <haifeng.xu@...pee.com>
To: akpm@...ux-foundation.org
Cc: mhocko@...e.com, david@...hat.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Haifeng Xu <haifeng.xu@...pee.com>
Subject: [PATCH 3/3] mm/mm_init.c: do not calculate zone_start_pfn/zone_end_pfn in zone_absent_pages_in_node()
In calculate_node_totalpages(), zone_start_pfn/zone_end_pfn are
calculated in zone_spanned_pages_in_node(), so use them as parameters
instead of node_start_pfn/node_end_pfn and the duplicated calculation
process can de dropped.
Signed-off-by: Haifeng Xu <haifeng.xu@...pee.com>
---
mm/mm_init.c | 35 ++++++++++++-----------------------
1 file changed, 12 insertions(+), 23 deletions(-)
diff --git a/mm/mm_init.c b/mm/mm_init.c
index 898af4eb9ce2..88c4a9266e2a 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1166,23 +1166,11 @@ unsigned long __init absent_pages_in_range(unsigned long start_pfn,
/* Return the number of page frames in holes in a zone on a node */
static unsigned long __init zone_absent_pages_in_node(int nid,
unsigned long zone_type,
- unsigned long node_start_pfn,
- unsigned long node_end_pfn)
+ unsigned long zone_start_pfn,
+ unsigned long zone_end_pfn)
{
- unsigned long zone_low = arch_zone_lowest_possible_pfn[zone_type];
- unsigned long zone_high = arch_zone_highest_possible_pfn[zone_type];
- unsigned long zone_start_pfn, zone_end_pfn;
unsigned long nr_absent;
- if (!node_start_pfn && !node_end_pfn)
- return 0;
-
- zone_start_pfn = clamp(node_start_pfn, zone_low, zone_high);
- zone_end_pfn = clamp(node_end_pfn, zone_low, zone_high);
-
- adjust_zone_range_for_zone_movable(nid, zone_type,
- node_start_pfn, node_end_pfn,
- &zone_start_pfn, &zone_end_pfn);
nr_absent = __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
/*
@@ -1254,6 +1242,7 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
unsigned long node_end_pfn)
{
unsigned long realtotalpages = 0, totalpages = 0;
+ int nid = pgdat->node_id;
enum zone_type i;
for (i = 0; i < MAX_NR_ZONES; i++) {
@@ -1262,15 +1251,15 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
unsigned long spanned, absent;
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);
+ spanned = zone_spanned_pages_in_node(nid, i,
+ node_start_pfn,
+ node_end_pfn,
+ &zone_start_pfn,
+ &zone_end_pfn);
if (spanned) {
- absent = zone_absent_pages_in_node(pgdat->node_id, i,
- node_start_pfn,
- node_end_pfn);
+ absent = zone_absent_pages_in_node(nid, i,
+ zone_start_pfn,
+ zone_end_pfn);
real_size = spanned - absent;
zone->zone_start_pfn = zone_start_pfn;
} else {
@@ -1289,7 +1278,7 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
pgdat->node_spanned_pages = totalpages;
pgdat->node_present_pages = realtotalpages;
- pr_debug("On node %d totalpages: %lu\n", pgdat->node_id, realtotalpages);
+ pr_debug("On node %d totalpages: %lu\n", nid, realtotalpages);
}
static unsigned long __init calc_memmap_size(unsigned long spanned_pages,
--
2.25.1
Powered by blists - more mailing lists