From: Sang-Heon Jeon <ekffu200098@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Mike Rapoport <rppt@kernel.org>
Cc: linux-mm@kvack.org
Subject: [PATCH v2] mm/mm_init: remove zone_absent_pages_in_node()
Date: Wed, 2 Sep 2026 01:51:49 +0900 [thread overview]
Message-ID: <20260901165205.1025640-1-ekffu200098@gmail.com> (raw)
zone_absent_pages_in_node() returns 0 when the zone is empty and
otherwise calls __absent_pages_in_range(), which already returns 0 for
an empty range.
So add an early return to __absent_pages_in_range() to avoid looping over
the memory ranges, then remove zone_absent_pages_in_node() and call
__absent_pages_in_range() directly.
No functional change.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
Changes from v1 [1]
- Add an early return to __absent_pages_in_range()
[1] https://lore.kernel.org/all/20260827144151.486192-1-ekffu200098@gmail.com/
---
mm/mm_init.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/mm/mm_init.c b/mm/mm_init.c
index 1533aebafb68..c00ac947a7d6 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1166,6 +1166,10 @@ static unsigned long __init __absent_pages_in_range(int nid,
unsigned long start_pfn, end_pfn;
int i;
+ /* range is empty, nothing to do */
+ if (!nr_absent)
+ return 0;
+
for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) {
start_pfn = clamp(start_pfn, range_start_pfn, range_end_pfn);
end_pfn = clamp(end_pfn, range_start_pfn, range_end_pfn);
@@ -1187,22 +1191,9 @@ unsigned long __init absent_pages_in_range(unsigned long start_pfn,
return __absent_pages_in_range(MAX_NUMNODES, start_pfn, end_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 zone_start_pfn,
- unsigned long zone_end_pfn)
-{
- /* zone is empty, we don't have any absent pages */
- if (zone_start_pfn == zone_end_pfn)
- return 0;
-
- return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
-}
-
/*
* Return the number of pages a zone spans in a node, including holes
- * present_pages = zone_spanned_pages_in_node() - zone_absent_pages_in_node()
+ * present_pages = zone_spanned_pages_in_node() - __absent_pages_in_range()
*/
static unsigned long __init zone_spanned_pages_in_node(int nid,
unsigned long zone_type,
@@ -1292,9 +1283,8 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
node_end_pfn,
&zone_start_pfn,
&zone_end_pfn);
- absent = zone_absent_pages_in_node(pgdat->node_id, i,
- zone_start_pfn,
- zone_end_pfn);
+ absent = __absent_pages_in_range(pgdat->node_id, zone_start_pfn,
+ zone_end_pfn);
real_size = spanned - absent;
--
2.43.0
next reply other threads:[~2026-09-01 16:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 16:51 Sang-Heon Jeon [this message]
2026-09-01 18:36 ` [PATCH v2] mm/mm_init: remove zone_absent_pages_in_node() Mike Rapoport
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260901165205.1025640-1-ekffu200098@gmail.com \
--to=ekffu200098@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=rppt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.