* [PATCH] mm/mm_init: remove zone_absent_pages_in_node()
@ 2026-08-27 14:41 Sang-Heon Jeon
2026-08-31 7:37 ` Mike Rapoport
0 siblings, 1 reply; 4+ messages in thread
From: Sang-Heon Jeon @ 2026-08-27 14:41 UTC (permalink / raw)
To: Mike Rapoport, Andrew Morton; +Cc: linux-kernel, linux-mm
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 remove it and call __absent_pages_in_range() directly.
No functional change.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
mm/mm_init.c | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/mm/mm_init.c b/mm/mm_init.c
index d87166a36ee8..1ead4d694099 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1192,22 +1192,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,
@@ -1297,9 +1284,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
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] mm/mm_init: remove zone_absent_pages_in_node()
2026-08-27 14:41 [PATCH] mm/mm_init: remove zone_absent_pages_in_node() Sang-Heon Jeon
@ 2026-08-31 7:37 ` Mike Rapoport
2026-08-31 11:30 ` Sang-Heon Jeon
0 siblings, 1 reply; 4+ messages in thread
From: Mike Rapoport @ 2026-08-31 7:37 UTC (permalink / raw)
To: Sang-Heon Jeon; +Cc: Mike Rapoport, Andrew Morton, linux-kernel, linux-mm
> 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.
Right, but it loops over memblock memory for an empty zone to get that 0
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm/mm_init: remove zone_absent_pages_in_node()
2026-08-31 7:37 ` Mike Rapoport
@ 2026-08-31 11:30 ` Sang-Heon Jeon
2026-09-01 6:27 ` Mike Rapoport
0 siblings, 1 reply; 4+ messages in thread
From: Sang-Heon Jeon @ 2026-08-31 11:30 UTC (permalink / raw)
To: Mike Rapoport; +Cc: Andrew Morton, linux-kernel, linux-mm
Hi,
On Mon, Aug 31, 2026 at 4:37 PM Mike Rapoport <rppt@kernel.org> wrote:
>
> > 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.
>
> Right, but it loops over memblock memory for an empty zone to get that 0
Indeed. How about adding an early return in __absent_pages_in_range()
to avoid unnecessary iteration? I just want to remove the wrapper,
which never uses its zone_type argument since eb0e5b61369f
("mm/mm_init: don't overlap NORMAL and MOVABLE zones with
kernelcore=mirror")
unsigned long nr_absent = range_end_pfn - range_start_pfn;
unsigned long start_pfn, end_pfn;
int i;
+ 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);
> --
> Sincerely yours,
> Mike.
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] mm/mm_init: remove zone_absent_pages_in_node()
2026-08-31 11:30 ` Sang-Heon Jeon
@ 2026-09-01 6:27 ` Mike Rapoport
0 siblings, 0 replies; 4+ messages in thread
From: Mike Rapoport @ 2026-09-01 6:27 UTC (permalink / raw)
To: Sang-Heon Jeon; +Cc: Andrew Morton, linux-kernel, linux-mm
On Mon, Aug 31, 2026 at 08:30:40PM +0900, Sang-Heon Jeon wrote:
> Hi,
>
> On Mon, Aug 31, 2026 at 4:37 PM Mike Rapoport <rppt@kernel.org> wrote:
> >
> > > 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.
> >
> > Right, but it loops over memblock memory for an empty zone to get that 0
>
> Indeed. How about adding an early return in __absent_pages_in_range()
> to avoid unnecessary iteration? I just want to remove the wrapper,
> which never uses its zone_type argument since eb0e5b61369f
> ("mm/mm_init: don't overlap NORMAL and MOVABLE zones with
> kernelcore=mirror")
>
> unsigned long nr_absent = range_end_pfn - range_start_pfn;
> unsigned long start_pfn, end_pfn;
> int i;
>
> + if (!nr_absent)
Yes, just please add a comment:
/* range is empty, nothing to do */
> + 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);
>
> > --
> > Sincerely yours,
> > Mike.
> >
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-01 6:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-27 14:41 [PATCH] mm/mm_init: remove zone_absent_pages_in_node() Sang-Heon Jeon
2026-08-31 7:37 ` Mike Rapoport
2026-08-31 11:30 ` Sang-Heon Jeon
2026-09-01 6:27 ` Mike Rapoport
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®