From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 E8C9E47010D for ; Fri, 14 Aug 2026 13:38:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786714682; cv=none; b=ifAxhmwuG/uuv89c8hRVaBpsJjEVosqObx2MJm0JOeKHhMEAxva3dCfIV+8Q0sEkS+bnuHMrDhDy6o/iaUbg309YUQNm8wLFrV/mWIGyUJeo1bfyL/j0pmNx2QlfsiWFjaUiJYKluVw+EhTEfZ2ojcChbAn7wjolc1U/MlprPp8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786714682; c=relaxed/simple; bh=GUn11COxY7dlVHUG6fMwFXtm+WiUl3fqxgUSSIIFSj4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QeHsHCfaOJGR4drzYizrlf6dvi7kO0O1CGsjO1ng7hkR1Vou0UX2Kr8KSl0wH8fik+HSpZn9mIk5JXRHzkFsUjUBFPMnm6A07kJcT+iuHQF+WxJfe+gRpn55vQqRAPzXR4F2htJEXt7XkeR5OSjrMk/KKutf6k7MYWGafss+Wy8= 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=P8DeAU9a; arc=none smtp.client-ip=209.85.214.175 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="P8DeAU9a" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2cf50c6f235so12490175ad.0 for ; Fri, 14 Aug 2026 06:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786714680; x=1787319480; 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=R/JrFNgP7KAnnpbgz8+ogMO9rc4uMT0klBiW388KiSg=; b=P8DeAU9aj8b706pHr3e+xLBAmWr/KanvikRBNgBwTVHkG8LQaaN9D0abErobi5JbmJ PPGO1bXMzceJUsj0cjHR16cs1EOl7hA41UFvXExrtrw/3XmkG0+Woqz0pDkFno7jsvdJ sDw7FzeATYvwqzQmlYKF8MtD2OLKu7cKR/UpFX/PsircMT+gFFy6t8S76AZyjS/40itY uorziTgbJBXRL0RribD/BYkXL7kr6LsP2oRP4LHHsV9vqE29TYhYYKL1046X61kOfdAM m7zLBZVIOCsg/VM8rf+3Dh8cbTh17mXuqShxhjuHwXr8mc7+gcww3W2p51rHsplPeXHY vzTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786714680; x=1787319480; 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=R/JrFNgP7KAnnpbgz8+ogMO9rc4uMT0klBiW388KiSg=; b=cs3TlxU8sEd+k4uShW+13BgOUdy07t1cUYG9a9acQbtIFz3Xj0MlHwUKSi3anXRcls 8vGRYVjClZV0BQxKaBDq0c8qEYXCxHHObahzSHASaX9XoUQqcinU05yxFSLhiXgXe5by EEuiK3+vzNf5fmIhVKa4avO8Y+WDCpbv5wrFhcBEezJJDwsnXV7K1qB5tc3UAkZJ/Q3l fv87ycQlNNZQPnilqEdAdpnfS676fMYVLBjyM+9iiHrDGY7M9JVc8zSMm86X/GkuDd/1 wUImjsvYUEaSb6Kl4BN9D0JylPYao+lN+lkxaiEmLnDqk876DbA77E1QVsEBUKYExDYn tLBw== X-Gm-Message-State: AOJu0YyO42/h2/eNdDlJ3J5aZI9Hy98swElKxbAUv/kSt3k39dcPRf2w MfxiEWZYgro4sM8lfRG/z0z1UCZjeIsrIc8HQK5wx2Rv0odn8Mbm6MXU X-Gm-Gg: AR+sD11sgHZbOluWvyiyzeBVFHUVUluqPh8xIwElNUgXB44aANe0FYZ+p3BwnJwv2uG yC3eGB2o/YlAxF5vXjAUHtHCa/lFG9rYR8hLuidPs41mNBQsJeTX8DCQVsX5xdxxcn7+unND5iE sfUCzn0BwaZJqBS7x0OMrhpH/PEKI0llFX5qyayHDY4VIdofHbYCOPmIel+egpLyuFZEl/Dy4l2 SwEkbWPuFw0CXKOYF30U5HfCx+R4yVvPy0mBT1sLi+dQm/sH1AMEmpHlfxNORGYsiUNZx1WPQ9E 4RNePT98F9YmHxWS7kSrsMDck9mAcs9X0kfVCMuIvyfQDigtrKwrlmMx0AkFqToePpDQ0KD+fce nr5pkKuXeMpxuiYb+pnqv9BZeffx2az+HWDMA2qynqq7vkJ5PntxyfMAJy3vgrAhu5ynKTJ0GEp nR7zhFtd9jKffTZG+j359AWEUL5sMH1x9JfoZofsLcsB/mIEXM8dfWuTc= X-Received: by 2002:a17:903:37c7:b0:2c7:f2c6:89e0 with SMTP id d9443c01a7336-2d3b08053b6mr72313705ad.4.1786714679940; Fri, 14 Aug 2026 06:37:59 -0700 (PDT) Received: from ubuntu.. ([110.9.142.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d3ae79f0cesm10029415ad.18.2026.08.14.06.37.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2026 06:37:59 -0700 (PDT) From: Sang-Heon Jeon To: Mike Rapoport , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v3 1/2] mm/mm_init: fold adjust_zone_range_for_zone_movable() into its only caller Date: Fri, 14 Aug 2026 22:37:38 +0900 Message-ID: <20260814133744.2746782-2-ekffu200098@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260814133744.2746782-1-ekffu200098@gmail.com> References: <20260814133744.2746782-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 adjust_zone_range_for_zone_movable() adjusts zone_start_pfn and zone_end_pfn. It is only called from zone_spanned_pages_in_node(), which adjusts the same two values before and after the call. This makes the code harder to follow. Fold the helper into the caller to make the code clearer. Also extract zone_movable_pfn[nid], which is used four times, into a local variable and skip the adjustment early to reduce the indentation level. No functional change. Signed-off-by: Sang-Heon Jeon --- mm/mm_init.c | 68 ++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index eb53c327210b..df67d4e6f646 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1124,41 +1124,6 @@ void __ref memmap_init_zone_device(struct zone *zone, } #endif -/* - * The zone ranges provided by the architecture do not include ZONE_MOVABLE - * because it is sized independent of architecture. Unlike the other zones, - * the starting point for ZONE_MOVABLE is not fixed. It may be different - * in each node depending on the size of each node and how evenly kernelcore - * is distributed. This helper function adjusts the zone ranges - * provided by the architecture for a given node by using the end of the - * highest usable zone for ZONE_MOVABLE. This preserves the assumption that - * zones within a node are in order of monotonic increases memory addresses - */ -static void __init adjust_zone_range_for_zone_movable(int nid, - unsigned long zone_type, - unsigned long node_end_pfn, - unsigned long *zone_start_pfn, - unsigned long *zone_end_pfn) -{ - /* Only adjust if ZONE_MOVABLE is on this node */ - if (zone_movable_pfn[nid]) { - /* Size ZONE_MOVABLE */ - if (zone_type == ZONE_MOVABLE) { - *zone_start_pfn = zone_movable_pfn[nid]; - *zone_end_pfn = min(node_end_pfn, - arch_zone_highest_possible_pfn[movable_zone]); - - /* 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]; - - /* Check if this whole range is within ZONE_MOVABLE */ - } else if (*zone_start_pfn >= zone_movable_pfn[nid]) - *zone_start_pfn = *zone_end_pfn; - } -} - /* * Return the number of holes in a range on a node. If nid is MAX_NUMNODES, * then all holes in the requested range will be accounted for. @@ -1208,6 +1173,15 @@ static unsigned long __init zone_absent_pages_in_node(int nid, /* * 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() + * + * The zone ranges provided by the architecture do not include ZONE_MOVABLE + * because it is sized independent of architecture. Unlike the other zones, + * the starting point for ZONE_MOVABLE is not fixed. It may be different + * in each node depending on the size of each node and how evenly kernelcore + * is distributed. The zone ranges provided by the architecture are adjusted + * for a given node by using the end of the highest usable zone for + * ZONE_MOVABLE. This preserves the assumption that zones within a node are + * in order of monotonic increases memory addresses */ static unsigned long __init zone_spanned_pages_in_node(int nid, unsigned long zone_type, @@ -1218,13 +1192,33 @@ static unsigned long __init zone_spanned_pages_in_node(int nid, { unsigned long zone_low = arch_zone_lowest_possible_pfn[zone_type]; unsigned long zone_high = arch_zone_highest_possible_pfn[zone_type]; + unsigned long movable_pfn = zone_movable_pfn[nid]; /* Get the start and end of the zone */ *zone_start_pfn = clamp(node_start_pfn, zone_low, zone_high); *zone_end_pfn = clamp(node_end_pfn, zone_low, zone_high); - adjust_zone_range_for_zone_movable(nid, zone_type, node_end_pfn, - zone_start_pfn, zone_end_pfn); + /* Nothing to adjust if ZONE_MOVABLE is not on this node */ + if (!movable_pfn) + goto out; + + /* Size ZONE_MOVABLE */ + if (zone_type == ZONE_MOVABLE) { + *zone_start_pfn = movable_pfn; + *zone_end_pfn = min(node_end_pfn, + arch_zone_highest_possible_pfn[movable_zone]); + + /* Adjust for ZONE_MOVABLE starting within this range */ + } else if (*zone_start_pfn < movable_pfn && + *zone_end_pfn > movable_pfn) { + *zone_end_pfn = movable_pfn; + + /* Check if this whole range is within ZONE_MOVABLE */ + } else if (*zone_start_pfn >= movable_pfn) { + *zone_start_pfn = *zone_end_pfn; + } + +out: /* 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; -- 2.43.0