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

Sang-Heon Jeon <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.kernel.mm
Message-ID <[email protected]>
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 <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.