[PATCH v2 2/5] mm/mm_init: remove redundant clamping in zone_spanned_pages_in_node()

Sang-Heon Jeon <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.kernel.mm
Message-ID <[email protected]>
Clamping *zone_end_pfn to node_end_pfn has no effect, because
*zone_end_pfn <= node_end_pfn is guaranteed at that point.

1. If zone_movable_pfn[nid] != 0 && zone_type == ZONE_MOVABLE,
   *zone_end_pfn = min(node_end_pfn, ...) <= node_end_pfn.

2. Else If zone_movable_pfn[nid] != 0 &&
   *zone_start_pfn < zone_movable_pfn[nid] < *zone_end_pfn,
   *zone_end_pfn = zone_movable_pfn[nid].

   The condition requires the clamped *zone_start_pfn and
   *zone_end_pfn to differ, which cannot happen when node_end_pfn <
   zone_low.

   So zone_movable_pfn[nid] < clamped *zone_end_pfn =
   min(node_end_pfn, zone_high) <= node_end_pfn.

3. Else *zone_end_pfn = clamp(node_end_pfn, zone_low, zone_high)

   a. If node_end_pfn >= zone_low, *zone_end_pfn =
      min(node_end_pfn, zone_high) <= node_end_pfn.

   b. If node_end_pfn < zone_low, *zone_start_pfn = zone_low >
      node_end_pfn, so the function returns 0 before the clamping is
      executed.

So remove it.

No functional change.

Signed-off-by: Sang-Heon Jeon <[email protected]>
---
 mm/mm_init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 30d3125951f0..bdc15de0a62a 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1219,8 +1219,7 @@ static unsigned long __init zone_spanned_pages_in_node(int nid,
 	if (*zone_end_pfn < node_start_pfn || *zone_start_pfn > node_end_pfn)
 		return 0;
 
-	/* Move the zone boundaries inside the node if necessary */
-	*zone_end_pfn = min(*zone_end_pfn, node_end_pfn);
+	/* Move the zone start inside the node if necessary */
 	*zone_start_pfn = max(*zone_start_pfn, node_start_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.