From nobody Fri Aug 14 15:48:44 2026 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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 -/* - * 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 kernelco= re - * 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 =3D=3D ZONE_MOVABLE) { - *zone_start_pfn =3D zone_movable_pfn[nid]; - *zone_end_pfn =3D 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 =3D zone_movable_pfn[nid]; - - /* Check if this whole range is within ZONE_MOVABLE */ - } else if (*zone_start_pfn >=3D zone_movable_pfn[nid]) - *zone_start_pfn =3D *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_nod= e(int nid, /* * Return the number of pages a zone spans in a node, including holes * present_pages =3D zone_spanned_pages_in_node() - zone_absent_pages_in_n= ode() + * + * 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 kernelco= re + * is distributed. The zone ranges provided by the architecture are adjust= ed + * 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_n= ode(int nid, { unsigned long zone_low =3D arch_zone_lowest_possible_pfn[zone_type]; unsigned long zone_high =3D arch_zone_highest_possible_pfn[zone_type]; + unsigned long movable_pfn =3D zone_movable_pfn[nid]; =20 /* Get the start and end of the zone */ *zone_start_pfn =3D clamp(node_start_pfn, zone_low, zone_high); *zone_end_pfn =3D 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); =20 + /* Nothing to adjust if ZONE_MOVABLE is not on this node */ + if (!movable_pfn) + goto out; + + /* Size ZONE_MOVABLE */ + if (zone_type =3D=3D ZONE_MOVABLE) { + *zone_start_pfn =3D movable_pfn; + *zone_end_pfn =3D 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 =3D movable_pfn; + + /* Check if this whole range is within ZONE_MOVABLE */ + } else if (*zone_start_pfn >=3D movable_pfn) { + *zone_start_pfn =3D *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; --=20 2.43.0 From nobody Fri Aug 14 15:48:44 2026 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (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 D7FC947010F for ; Fri, 14 Aug 2026 13:38:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786714684; cv=none; b=MtAVf7IgXMo99C4BxQKkFYk94mPU2dwdiNLwDCDZNiqhrMa6joyYEV2qoXklvTGFZDl5uMQd07LHX0IUIpSMs+qtNg6CXBgVTwSGpT9cSicJwR7gG/GxjCsXLkuxNuV69gGX278QOC8h/W8blWZhOfBr6Wz0ZOfr0Fo4iY5xa18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786714684; c=relaxed/simple; bh=qDIau3ORF52CXtlLjAy2KQmuFU2TiU2YK0YH7VMZXFA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dP4AW0xeoSkwUNz6IfrOkkIVwux0yRhYk3P3FvyA0gJ7N4cdiWyeWrDfSZwjz5f9hj3WfOQfR9+hLwL4dG+JAKVolu6Y6j5GiIBysEhaSrzC/Hf9YqjqwPoTNiT+HSHmbCX+VZIWgIOq1HNdnKffuVG7TmCR8UUrmMfh2OUl5Gw= 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=FmCVNrUK; arc=none smtp.client-ip=209.85.214.171 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="FmCVNrUK" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2d530328efbso2990235ad.0 for ; Fri, 14 Aug 2026 06:38:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786714682; x=1787319482; 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=JI2/0itjYyHQxm0VbGunPbHPq2EnTmm4Qfz9jXF5j54=; b=FmCVNrUKKncDRauL1VYzvquFOQvIC4On76AgobOBvNCaKMwu5Vgmz5e7bwjOuJPn1L RJTtU+IbtJHkHOE10wi9b2hh/HcrgZ6BQRDHDz1fGQ/Tp6Ep31riGox5UEfh9c3KwLU0 h9Emz1W1AzC9uBtkGzj/6y00eoiZrlW0zAJU2yb7cYD7gNUSllvhJ1ApIU42G3gRSRrO f+9ki0zELoIzHRFZrRYjOFZqvazWSdAMYinBMev9dvUZtkMxMspjUm8RqLaS+5PfJY+i yBHzozulyQeBPGTOSKakrNh7xT6Hszm4FP6eayxOp3zxdifwSB+zfJ6Gy1B0RYfNfYVH uoQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786714682; x=1787319482; 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=JI2/0itjYyHQxm0VbGunPbHPq2EnTmm4Qfz9jXF5j54=; b=oJ3HydCaqid5liTyD5b+XkWz27Wa8RtfnW2oxQwtmkZiaP4HmIlD4S7xtZT0woWsN0 MNme2J4ut7Sd1qw17YnzlGaXZEqW1P8uIZygt2gnoU5xiNO2NjARrIxvZzeARCCoiPcN rEAfDHGSqsM3lD6MNdHjX/xqbr45H82rMsXFx05FTrjSgMVu08eYTuA4vf2waXD/6tdM 7UjEV7clJ5pIECkszxtNqWekQeAdYj+OXfyBHELZYmaLup5u/dk9DWMcMqQNyZ5IlZq6 0Usu8gDzbQ60jP5fsCZcr1MJkgzvO6JXsDy2yATKCkuOfkWd4nPI8odc3My/WdS4ABro FriQ== X-Gm-Message-State: AOJu0Yxzk/O8avwSWwZS4fuv6FIApBWa3vCAlObSyec2+chD8UbkevyT Rdg+zukV1WO6mP8Y6aatXrkqvOmSMe3z6kGTqBknctlXDM+HFLPilSjeaR34dQ== X-Gm-Gg: AR+sD11NgclJBJZ+LTJmirdpHncBANr37Z++TDsShKbcSi9fFsSNFtJeGkEI3D69ize 8/aCZ/Ccei6mSZZdcm10i1bgfcxPIxPJi/LBkOUdX0jqPBnBqYsSKlb2IlEoeITvEuZAZKGs2QL D9BkRgUBUgZ6jZh9txS8jSvft6EvpLVCqvBjthhS2Vmhs9UEtKvQn8fdXlkYiFkIX7N5v305J+5 fmjbzo5uCGT455jlmjdR6hhy8XtX8yUliULU5IlBQO5kBvS6eZ5wGuyHWSJjy0CeV1amolxtNi1 obkxhNGWEkgQITdCpYwGYyF3fJYLRtLmV27yBuSbm3fQeXUH4VVXeKw6jWbNhoXYmyRslebr7ll sQv+Qn92QueRbFcX7Cm6nNRNGKf4EB8glHdwjblwG3r4BCDH61pQiLmB/73FePU3r2Yd76o814S 9ZuJQ6iWYbW5Pa0JIfoIb2NsMSxwsg5SdOyyhTseHoZpdp0Z8RCazHg8c7PDe5 X-Received: by 2002:a17:902:da92:b0:2cf:9f0b:b562 with SMTP id d9443c01a7336-2d3b0cf922amr67460265ad.22.1786714682061; Fri, 14 Aug 2026 06:38:02 -0700 (PDT) Received: from ubuntu.. ([110.9.142.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d3ae79f0cesm10029415ad.18.2026.08.14.06.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2026 06:38:01 -0700 (PDT) From: Sang-Heon Jeon To: Mike Rapoport , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v3 2/2] mm/mm_init: simplify ZONE_MOVABLE branch in zone_spanned_pages_in_node() Date: Fri, 14 Aug 2026 22:37:39 +0900 Message-ID: <20260814133744.2746782-3-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: quoted-printable Content-Type: text/plain; charset="utf-8" *zone_start_pfn and *zone_end_pfn are first assigned clamp(node_start_pfn, zone_low, zone_high) and clamp(node_end_pfn, zone_low, zone_high). If movable_pfn !=3D 0, the branches adjust them as follows. 1. If zone_type =3D=3D ZONE_MOVABLE, *zone_start_pfn =3D movable_pfn, which can be outside the node, and *zone_end_pfn =3D min(node_end_pfn, ...), which is at most node_end_pfn. 2. Else If *zone_start_pfn < movable_pfn < *zone_end_pfn, *zone_end_pfn =3D movable_pfn. 3. Else If *zone_start_pfn >=3D movable_pfn, *zone_start_pfn =3D *zone_end_pfn. 4. Else *zone_start_pfn < movable_pfn && *zone_end_pfn <=3D movable_pfn, and nothing is assigned. If node_end_pfn < zone_low or node_start_pfn > zone_high, *zone_start_pfn and *zone_end_pfn are both zone_low or both zone_high, outside the node. Then case 2 cannot apply, in case 3 *zone_start_pfn =3D *zone_end_pfn, which is that same pfn, and in case 4 nothing is assigned. So the check against node_start_pfn and node_end_pfn returns 0 early. Otherwise node_start_pfn <=3D *zone_start_pfn <=3D *zone_end_pfn <=3D node_end_pfn. Then in case 2 *zone_end_pfn =3D movable_pfn, in case 3 *zone_start_pfn =3D *zone_end_pfn, and in case 4 nothing is assigned. So *zone_start_pfn and *zone_end_pfn stay within the node, the check does not return 0, and min(*zone_end_pfn, node_end_pfn) and max(*zone_start_pfn, node_start_pfn) change nothing. So the check, min(*zone_end_pfn, node_end_pfn), and max(*zone_start_pfn, node_start_pfn) only have an effect in case 1. Also, cases 2 and 4 both have *zone_start_pfn < movable_pfn, and min(*zone_end_pfn, movable_pfn) is movable_pfn in case 2 and *zone_end_pfn in case 4. So the two cases can be merged into one branch and case 3 becomes its else. So remove *zone_end_pfn =3D min(*zone_end_pfn, node_end_pfn), move the check and *zone_start_pfn =3D max(*zone_start_pfn, node_start_pfn) inside the ZONE_MOVABLE branch, and merge cases 2 and 4 with *zone_end_pfn =3D min(*zone_end_pfn, movable_pfn). No functional change. Signed-off-by: Sang-Heon Jeon --- mm/mm_init.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index df67d4e6f646..ab445111a846 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1208,25 +1208,24 @@ static unsigned long __init zone_spanned_pages_in_n= ode(int nid, *zone_end_pfn =3D min(node_end_pfn, arch_zone_highest_possible_pfn[movable_zone]); =20 - /* Adjust for ZONE_MOVABLE starting within this range */ - } else if (*zone_start_pfn < movable_pfn && - *zone_end_pfn > movable_pfn) { - *zone_end_pfn =3D movable_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; =20 - /* Check if this whole range is within ZONE_MOVABLE */ - } else if (*zone_start_pfn >=3D movable_pfn) { + /* Move the zone start inside the node if necessary */ + *zone_start_pfn =3D max(*zone_start_pfn, node_start_pfn); + + /* This range starts below ZONE_MOVABLE */ + } else if (*zone_start_pfn < movable_pfn) { + *zone_end_pfn =3D min(*zone_end_pfn, movable_pfn); + + /* This whole range is within ZONE_MOVABLE */ + } else { *zone_start_pfn =3D *zone_end_pfn; } =20 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; - - /* Move the zone boundaries inside the node if necessary */ - *zone_end_pfn =3D min(*zone_end_pfn, node_end_pfn); - *zone_start_pfn =3D max(*zone_start_pfn, node_start_pfn); - /* Return the spanned pages */ return *zone_end_pfn - *zone_start_pfn; } --=20 2.43.0