[PATCH v2 4/5] mm/mm_init: use min() when adjusting for ZONE_MOVABLE

From: Sang-Heon Jeon

Date: Thu Aug 06 2026 - 12:27:30 EST


Outside the ZONE_MOVABLE branch, the two branches set *zone_start_pfn
and *zone_end_pfn as follows.

1. If *zone_start_pfn < zone_movable_pfn[nid], *zone_end_pfn ends up as
min(*zone_end_pfn, zone_movable_pfn[nid]).

a. If *zone_end_pfn > zone_movable_pfn[nid], *zone_end_pfn =
zone_movable_pfn[nid].

b. If *zone_end_pfn <= zone_movable_pfn[nid], *zone_end_pfn is
unchanged.

2. Else *zone_start_pfn >= zone_movable_pfn[nid] and the whole range is
within ZONE_MOVABLE, so *zone_start_pfn = *zone_end_pfn.

So use min() to simplify the conditions.

No functional change.

Signed-off-by: Sang-Heon Jeon <ekffu200098@xxxxxxxxx>
---
mm/mm_init.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index fa6b5977261f..27f454edbebb 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1213,14 +1213,14 @@ static unsigned long __init zone_spanned_pages_in_node(int nid,
/* Move the zone start inside the node if necessary */
*zone_start_pfn = max(*zone_start_pfn, node_start_pfn);

- /* Adjust for ZONE_MOVABLE starting within this range */
- } else if (*zone_start_pfn < zone_movable_pfn[nid] &&
- *zone_end_pfn > zone_movable_pfn[nid]) {
- *zone_end_pfn = zone_movable_pfn[nid];
+ /* This range starts below ZONE_MOVABLE */
+ } else if (*zone_start_pfn < zone_movable_pfn[nid]) {
+ *zone_end_pfn = min(*zone_end_pfn, zone_movable_pfn[nid]);

- /* Check if this whole range is within ZONE_MOVABLE */
- } else if (*zone_start_pfn >= zone_movable_pfn[nid])
+ /* This whole range is within ZONE_MOVABLE */
+ } else {
*zone_start_pfn = *zone_end_pfn;
+ }
}

/* Return the spanned pages */
--
2.43.0