From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 4250D3FD943 for ; Tue, 4 Aug 2026 14:48:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785854911; cv=none; b=P14/xtPoWTwLMa14DxgkqYtpO0Cx/8+KhWrK0GTVOuTrLKq3TKOa5hvf1HOS7jbC7YcWUKFXxDonqXaYe/p1UhjSU3oeGZ0phzoRRBpWm0Dq0lRtQZWi1WFwrz/B429Xl/YNMOqDVd+aI+9Fqoudbj1PfyAdsVkSY1uGPExdMUE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785854911; c=relaxed/simple; bh=smVhZ0fEfnigvkFhzxr3xNk7OiG9MPCGGJD9yidql4Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ryfuaEjcZ0iJwSjxysyiVGHgwxvpzv2EfBLQqzFDeGXOTbOcqjUY9ilZ8H5nzpsmA7Na/0MNuuUY6EF4+tOinnJkanJYcHAS5/qwEQKtG85Tnq4G32ZwXBSuEvEqr9U9wzxhD/NvBhJtdC43Cev7s0vZv7Ko4iTu/RYSoA4TKUg= 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=GZzhw0UA; arc=none smtp.client-ip=209.85.214.179 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="GZzhw0UA" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2d049069377so41568365ad.0 for ; Tue, 04 Aug 2026 07:48:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785854904; x=1786459704; 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=mR23Xel4iQAWEJiRA5QZMmGqrf9trThRl4S8g3S4noE=; b=GZzhw0UAiQqchf8na+IzJhjdT9WM1TIQL+0AVbmrJaHR67p2cKN73YIh9isMQblMXg Lx7rZZ1TkjCvYUQjZxOWcyXrvNBknBrxaSgzp273UKXvDzGjDdLKMyCw8TbhDG7ZadG7 O9nxtF0jTOjBtUkWiMQvtfPLJ1mPTJv+8OlhCMzSKLvHISv+HlKtm5sLhMT4u/sAmoJt L5CVjPjzVMdeEo1MlK/fYyIm919rxlrJOz49BH4PqesDRZRfxUgbMKQa1hxkjNMicOGt L6iMlz0UeZ3RZPohm6ncmjHUqo+5y5qDjV5h0J2Ca0yWESDiHlY5coSXjOJo1prcu8Cz mb0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785854904; x=1786459704; 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=mR23Xel4iQAWEJiRA5QZMmGqrf9trThRl4S8g3S4noE=; b=Eu+hGC3VBuX5Kn0ivdlJl2GwNNlDpXi98Awt1paA6jfGWJbKHJANczWCBycKfXb3vG Pr5siC6D/YiTx8X1GPqVOciEdIvQvbRbC32IxJACLCBRvN2zVp63Fr0M/hw2P0C6C4VH esAFBcF2uuxwBHcF9qqxpvERKw0+Io5wIZde2/gKdRQNABs6tJ8wKn1rOnSpIVNYNxCw 5ISTrvSGkk7+Uslc4YYEDpAVxwkw+hRJfDYmuWRU8ChqCC/ubSkHeh2HLb4sFUg2fIH3 G1jSSVJUy4Xg1muOke9HBW+M/lx8S6n5eY6i9mtiac2ZtqZgtLATp/2xm2IB8YJ5JTqR qTlg== X-Gm-Message-State: AOJu0YyhG7e0qfBiPiTQSM2MSd5U98+2mmEcz+NDkPK6EBAq38Qahuw6 B8J3g8bmzYBCXZc0COh9BSlwWI8pqhuNYHRlr5k9GasG3wMwCERlH53O X-Gm-Gg: AR+sD10/q0IFwzDYOO+hFmxCUwvVJV+TZZlNEWNolho0WtyKzlCKy6J6icRC/ch+JLN FcnnOOgXi3nsZujnzXyoEJtWQsjYzPajyo/Mj7ItoeOUs1SkD/oLQuHtfWk9rLwg+n63kxfR9A5 HIXgVKFLzQc+hkx2iOUP04lZHcuh+EU+pqWUc6aueVM//G8EVB1GtkCNOVqs0O8TwjdkGl7N2Gs kvOAXTFsA2jesDRNQ/DslWpdr5jcg+6OvVsN0VIJSjh9iDIrwezc6q5EiGzoVVlfqJkam/hSNal rftv5Y42AktL5Mkx/ISzyB6XeO9VarUsXq++uAp3A1W7Bc3mux5DikQ83MCgl2KlFXJffQcGZVX 2T5lZvOS0KyPlC4ALyQUrM7FtEYzRa7oqHrfmC6YplihGN8+mhnZJVnKvXrRM/a1H+j+Kp70KJE BBYX4YAH2XOtUogV0sbNhJDvJhaHGhCxG87FTvNDsnakjEb+FGa2I6+UI= X-Received: by 2002:a17:902:e945:b0:2ca:b4b9:4586 with SMTP id d9443c01a7336-2d0521e5d6cmr148874165ad.19.1785854903753; Tue, 04 Aug 2026 07:48:23 -0700 (PDT) Received: from ubuntu.. ([110.9.142.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d0aa4930e1sm8784175ad.41.2026.08.04.07.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 07:48:23 -0700 (PDT) From: Sang-Heon Jeon To: Mike Rapoport , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/4] mm/mm_init: fold adjust_zone_range_for_zone_movable() into its sole caller Date: Tue, 4 Aug 2026 23:47:58 +0900 Message-ID: <20260804144803.3290255-2-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 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. No functional change. Signed-off-by: Sang-Heon Jeon --- mm/mm_init.c | 66 ++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 38 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index 711f821f7b3c..ddff06467239 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1143,42 +1143,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 (!mirrored_kernelcore && - *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. @@ -1257,6 +1221,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, @@ -1271,8 +1244,25 @@ static unsigned long __init zone_spanned_pages_in_node(int 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); + + /* 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 (!mirrored_kernelcore && + *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; + } /* 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) -- 2.43.0