From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.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 474B543CEFE for ; Thu, 6 Aug 2026 16:21:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786033283; cv=none; b=aWqIXY+/hzZACcewl3f8YHc5KTp9mR+PUUaT8brDFOJeSGyUeMPb8k997xAedZOagy52eOSKTBSS3ci3WWWM0KN/LX1UrICbbjVACbDBk+A1pLhiMTFSN3rk5o3pbtpnUs838nfu+zbhxxOMNZm04xiwbBy7I/QsSY8SibTNw1I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786033283; c=relaxed/simple; bh=uGJt65PlftCW5oaUl0gPKwRz+euxiOXtgwMgtOoA+II=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s1NoZyMtXMu6d9HwTjFQ9cTqhmz3G8LGoBxYoaxkawwrMb5uU+stAjT4B5mGSIuGBtnU6kn5ujSwtGCSMg+zE1a75pIrt9r8MEkjJJ6ja600IRo3EzI9KxxOtDGfevE/97591StCJRiivg46xACklxyU+FRyEwZCSjBz5ZhKGzQ= 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=Pu2JIPg2; arc=none smtp.client-ip=209.85.210.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="Pu2JIPg2" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-8485ef63b68so3437335b3a.1 for ; Thu, 06 Aug 2026 09:21:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786033282; x=1786638082; 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=OV2ia1JQIR9t4BY0Y1KbMPnG4hxTayzchKqwFyoORUg=; b=Pu2JIPg2zOupMrjcn5okNrK+oFVIdQXZ6OQSW59QN59QkcR6dpyYjyIAiL9WPnX0/s ovOeljE9/qlIqvyIJWyvMnrcA1vFx+LcQv+WIHyh5qfeonfrRkwwmOS/84pHhHqcx0gn 7wtPmQ2uFqoal+aDr2PxpqlEbZEmsUKN8SfOd4lkO2x1OEKSlyH0Da1gD1F9xCMhNdsy Lj2CpigyjGJZtQy/1xIhULc6GpUBSEyL5KSnmQVsCGd9m8CzPScMpiVZm8h2PSRMx0Nl 3muPGfBtAzdzRIdeCr5miMdb0Vqozvn4uCCtGFgBq2Zl8hZEZfSpIYPikhhEHm1T+tcw eLRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786033282; x=1786638082; 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=OV2ia1JQIR9t4BY0Y1KbMPnG4hxTayzchKqwFyoORUg=; b=S/LyscYXHAVNSMx/qVJ1ufG+O/FUgWNT99WHFAYKt1QRO8qQPsKH5eQPa+N5TpwOKs XrSzYkpzfiJcRIwBFTE0XNrE2uH4c5CuDAunbyV2Bgj6J8c5hyN2xbSIDNg5LBOTqDd6 szMqIF4TS8qSghdS3LFscJ2M62vA69U0nD9dEL5o0ZKN5cpqhx+jyX6U+KVMyPESKQFp 57vTXhwchywAgbmp7PKpOkggAt7FohDh3G6bA1ECXlrtUslhPzj8NsOAwaB8BkViU53j NTeBUP1I7XDyunZfL/M+Bwbq4448hK/qH0TbXSfzm2+/nMHxhcMNuEvECorZMavgUquq 8JDw== X-Gm-Message-State: AOJu0Yz7wf/xjh67/KnMEOtwQF8N/Yi4QmVaLDwUH3wiFvkiUWvDQqUs l79MwlRWzaKTh8GjYhGGiY/6JQryz0bCjXolgPnBFyl94tcUBbhj7hj4 X-Gm-Gg: AR+sD13RqNe/bmTfFJyoXqlWHquQ/x+6dYqQHwGzRKwbS52nMBUlZdqS3HjCr4Xn32B DEfs1AH2rGe1KQPzVDoisQ74DTog1j2pqLRh/VRPYzswlhr6RP5YIeTJ/enIWKzSAa3VrJV/SdX JK+z398yoKpld1Ym3DlaT//YcvmU8FoCAbdweBd1S7ULVE9p2+mG8LK9qSFv9v0W/tBlevhRzTM E0gPfcDNoFkZWJHHKBYRuIFB6H/OnXylTzY7QuGQQLCCeW2atcKa9RbSJIuckbGx9EpxJNSDARP FOsjYUABHcARXiXMZ2yGiTAY1gZghTA5Bo9ZROOCR4YR9i3CUGQVtlTEpzHSME5VpRdiQBu1MdA TlzFeMV8kHLastlpln7rYF6Q4N3QCSwkM2T2hk9uCiY+lMEDYeitOekYdeI1z0PS5O0DvbdVB/7 xCssEszi8XeuEJhdx2iy02JLTTj/DZhVzg4TgFz0Ocx8vRiM4TkcbuZGY= X-Received: by 2002:a05:6a00:2d0b:b0:848:4d1a:9554 with SMTP id d2e1a72fcca58-84f2e0ed972mr17580183b3a.38.1786033281571; Thu, 06 Aug 2026 09:21:21 -0700 (PDT) Received: from ubuntu.. ([110.9.142.4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84f459b66e6sm1662739b3a.40.2026.08.06.09.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 09:21:20 -0700 (PDT) From: Sang-Heon Jeon To: Mike Rapoport , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 1/5] mm/mm_init: fold adjust_zone_range_for_zone_movable() into its only caller Date: Fri, 7 Aug 2026 01:20:52 +0900 Message-ID: <20260806162100.313965-2-ekffu200098@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260806162100.313965-1-ekffu200098@gmail.com> References: <20260806162100.313965-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 | 64 ++++++++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index eb53c327210b..30d3125951f0 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, @@ -1222,8 +1196,24 @@ 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 (*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