From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D89F944998F for ; Tue, 4 Aug 2026 14:48:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785854914; cv=none; b=gAwMY8ktTkBZeJ0v9Y86xc3KZZgl7i05M/+mVWbj62zOYRT1REgIf8yBHm4S129EIefMSF8uRl2wK84TnRczXngL5+EUGYn3gFnE3dWSiN/6Ng8do7IJyGt7u56R5CSo8NCWzYQdH883GrrEahgP7D4CmbrfBqN5468PjogWlAw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785854914; c=relaxed/simple; bh=cU70fDlZa+0+iBfYSOxNInvRsLeko1X2Rfbo3elxfVk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AlbQiY2YAYXHPN3aBkNv1NLCoAK6z8oobKy6m5+uOPEwqraZGqK7VRCdWio00v5GReW9hxfNA1usIe/jV7fTJIrs0zrQdyJOQN/iUcq4tuNoUkG1ljIr1KP0vU2c+/jjsvnHgtSAGMbpgxt3/nm+/wNyz8kktgRvWXWFDsc1DKc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RxX6N2TO; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RxX6N2TO" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2cacf197759so69671925ad.2 for ; Tue, 04 Aug 2026 07:48:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785854908; x=1786459708; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=y3Ke7fxV17DzCzcHb24D2luZMqAekIqqLL/76GU6lPQ=; b=RxX6N2TOJor2M7TOwYC60yKP58EVtABWaGkeF93YVdL4zT39cWgvTXsZqb/mGOmrC9 QZIcuvk8JBTDuVINoM9LcbStr+4w4fsgcEpyVJs4RGi13NxZFCyXyNlYQkrm3TbklojF q7sXP1Yk+AxIDRDRrc5UtaAuFFpL33VXUdeQlVuVepEFl7azb/qkOjuykq2t1PRVcs4h rrqURv5j9skqZs0v61RC2o7Gsi5AR39Z5liZokcFxhCtoyriBWNnS+ZuxEGFPLiATqtG SrPbC3lNLiTg4IM2Xju2AuITX2zN1+JodrW8ymg90DWfdOaLjuf7UAujJv2KagNNb9r/ Eozw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785854908; x=1786459708; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=y3Ke7fxV17DzCzcHb24D2luZMqAekIqqLL/76GU6lPQ=; b=HrlUk5f8zLAYLn3lYquae5zJpT0gVInI26s8FBUpaFspda2MUxQrNEgtemQhUValIR G9hqPAie/Ve4Qf3SP02dJyil0xzgrp/2UCO2WbSRkLUWsOvTOaqQQK8dE2N8ZWOk0rBv ilmUTThN36Wjy9aStF78NkhGkCeK+SbcSyXPCrjcC5xtH7rB/GoiFVF6swjyiR42O9K5 uKiva8ajrMzcbmr5R1KQd5hwB1LxFJCbzvNSrmJcjiQwcCYXmpi41rY9d+rmxCQJ5+sJ H202XUh+nU3HJgsj5rUCcc//UIqbcmUHdPapN27wNPsv37rQAC+Fclf63KgAi9cvHb+4 TNpg== X-Gm-Message-State: AOJu0Yw8UrzPL5ehEp18R/I391oKzbUuu0JYkDaGNaN6GjOnym5HD+QZ 7O4TsQyjZuTE3m4hdcL06nGehHKXEsCoh9qM8s23ACDA3FwwfuRcFQJc X-Gm-Gg: AR+sD10ucvNqptwaCTFbkXkC0KLEXnVQ3OycKNjo7yzw0MuhledEOc+N0WZhtkzP6pd PCQ13VkgBGUWKEucY86iLnhH18kux3lxrw0rJhulF+W6ljUvT0qqCNjJ7ZvIcos2elwHWelodyY xfLGAFAmqlDl37sgHAlwdD9RVZCABUlzDQbSa9oSxspDN9bMkJCy3jk794jyq+ouFvxGlpcV9oT 9cbmo+GOViEqEKZRCYmz/3eYRoDHQ64b5iALAJpjq2rNMuUthZU/l6gLvD4jO7SPIuwQcltCl05 yjLL/wFf7gEkk6o0TezEo8RwyjrL8AvUQdht8yC/H09S3m08k2/PM6FXeLM7PlmA18ehl6lTCgw sBVc2++vAFXQx2HBbKKdWgscB7CJ5idvbmp/mYV5thJZ5lgVUCqXlIk+W+WMNoPdro9BUpSfP7D YxOdYhWrqVBc+igXAl5E7HLnBRF7oHJdKTqWaAvKpvTifYn4+1nEG2eRo= X-Received: by 2002:a17:903:4b30:b0:2c9:e9c4:82c1 with SMTP id d9443c01a7336-2d0523b7cfdmr156995145ad.26.1785854907551; Tue, 04 Aug 2026 07:48:27 -0700 (PDT) Received: from ubuntu.. ([110.9.142.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d0aa4930e1sm8784175ad.41.2026.08.04.07.48.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 07:48:27 -0700 (PDT) From: Sang-Heon Jeon To: Mike Rapoport , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/4] mm/mm_init: move the range check and clamping inside ZONE_MOVABLE branch Date: Tue, 4 Aug 2026 23:48:00 +0900 Message-ID: <20260804144803.3290255-4-ekffu200098@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260804144803.3290255-1-ekffu200098@gmail.com> References: <20260804144803.3290255-1-ekffu200098@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Outside the ZONE_MOVABLE branch the check and the clamping have no effect, because every branch ends with one of the following. - *zone_start_pfn == *zone_end_pfn, so the function returns 0 anyway. - node_start_pfn <= *zone_start_pfn <= *zone_end_pfn <= node_end_pfn, so the check does not return 0 and max(*zone_start_pfn, node_start_pfn) is always *zone_start_pfn. The branches set *zone_start_pfn and *zone_end_pfn as follows. 1. If zone_movable_pfn[nid] != 0 && zone_type == ZONE_MOVABLE, *zone_start_pfn = zone_movable_pfn[nid] and *zone_end_pfn = min(node_end_pfn, ...). 2. Else If zone_movable_pfn[nid] != 0 && !mirrored_kernelcore && *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 or node_start_pfn > zone_high. So *zone_start_pfn = max(node_start_pfn, zone_low) >= node_start_pfn, and zone_movable_pfn[nid] < clamped *zone_end_pfn = min(node_end_pfn, zone_high) <= node_end_pfn. So node_start_pfn <= *zone_start_pfn < *zone_end_pfn <= node_end_pfn. 3. Else If zone_movable_pfn[nid] != 0 && *zone_start_pfn >= zone_movable_pfn[nid], *zone_start_pfn = *zone_end_pfn. 4. Else *zone_start_pfn = clamp(node_start_pfn, zone_low, zone_high) and *zone_end_pfn = clamp(node_end_pfn, zone_low, zone_high) a. If node_end_pfn < zone_low, *zone_start_pfn = *zone_end_pfn = zone_low. b. If node_start_pfn > zone_high, *zone_start_pfn = *zone_end_pfn = zone_high. c. If node_end_pfn >= zone_low && node_start_pfn <= zone_high, node_start_pfn <= *zone_start_pfn <= *zone_end_pfn <= node_end_pfn. So move both inside the ZONE_MOVABLE branch. No functional change. Signed-off-by: Sang-Heon Jeon --- mm/mm_init.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index 75fe1918d4d4..1190a27ed0fb 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1253,6 +1253,17 @@ static unsigned long __init zone_spanned_pages_in_node(int nid, *zone_end_pfn = min(node_end_pfn, arch_zone_highest_possible_pfn[movable_zone]); + /* + * Check that this node has pages within the + * zone's required range + */ + if (*zone_end_pfn < node_start_pfn || + *zone_start_pfn > node_end_pfn) + return 0; + + /* 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 (!mirrored_kernelcore && *zone_start_pfn < zone_movable_pfn[nid] && @@ -1264,13 +1275,6 @@ static unsigned long __init zone_spanned_pages_in_node(int nid, *zone_start_pfn = *zone_end_pfn; } - /* Check that this node has pages within the zone's required range */ - 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_start_pfn = max(*zone_start_pfn, node_start_pfn); - /* Return the spanned pages */ return *zone_end_pfn - *zone_start_pfn; } -- 2.43.0