From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 3333336604B for ; Fri, 21 Aug 2026 03:14:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787282077; cv=none; b=qXVyTSQ0AG/m3qGLHXfYADySFamb5sxK0Vdypm/NMk2bAEaE4jsgh/jaPXAMDlAq8hI7k36q2CeQQQPVAYvC6POZE4Dcnxo4YfWlF9V+TaQBjn5d1CI9iqEWsRsgExcVcygXoQMCNyhs54NcgjcpYjDjpyTO0ce1QShdLC+IOJU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787282077; c=relaxed/simple; bh=JONxlu1750bxIXYWOXdJdrCb/xDvQPDsimfhBFl6HHU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OdttotZsWW1gY0han5Bfba+Ctjysi2Pl3GyP5wsV4z4Cv0WhRVdW5mSHxnU4jYIQa6fybo4aLpvYKJWoZ/LmPN/78Ky88GiFWcI9EyQrAsV2OIVrUDamtYSKmfz6kh1yApF5p4Mh5GEEL+TCR+qHhaBWSiobG0vgOJblKAuhYl8= 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=ZyBHuB/k; arc=none smtp.client-ip=209.85.208.45 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="ZyBHuB/k" Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-6a082b3671fso969273a12.3 for ; Thu, 20 Aug 2026 20:14:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787282069; x=1787886869; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:content-type :mime-version:references:reply-to:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to:content-type; bh=nap+rM8Be8DqruXf+C67/tHyR/uuLBbAVCYucfCY/lU=; b=ZyBHuB/kLB9wNL1lhhr3gZI8Wb0y0aKwgRd3qttcuLZoMVGWxEeaS27U2MEq7RXFDP 5zkrYr+8dhg8p3xmk/yE0vlIeXV0uQfgdyb1rDoTpq2+AyHhRSqdMPm8FfFP4XC7Lk6g DIY6aGzpAeOOgXX0+/GBRmM3jKYpyOVpar0T6n8f16Qbmj5TH+CH9vAD/ecXsANewDm+ rmLKQKLFtfwqwjSJLmC/T49o1rJEcK9yG5xRjflmeiR885LILBw4Ah4hT8AKD3xFoVc+ 0Q82irsuWEVS3meucdCsesn3zllSNkr6HYaDBdZFKn/FSTLqKcN4dZF39U/cEGCshhzX pUNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787282069; x=1787886869; h=user-agent:in-reply-to:content-disposition:content-type :mime-version:references:reply-to:message-id:subject:cc:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=nap+rM8Be8DqruXf+C67/tHyR/uuLBbAVCYucfCY/lU=; b=Uo25FJm1zAdZHxIWRVHqa8i0nnvPwC2f4UeVgVAUy0Nagkd2vm8p7C4HBLlbfgfApw tQ1+BWIXuKUfz2YRFuU/eIFgb7pUdUcvRflk51Xd8lSMXC3HgNfUPA7xAKP+nGfSNQ9f XrNqjcRHqBYaZAHVDiVKONAvF1FhAJ0PVD61drrrSg7w+/ETwCqD20faHHHa3cSG6Ilh N0tlRxdb+EYHZ6ABvJkBxSm01NiMv7mXdAEV4aHxJFZZQBg9UAcewyGeAzBeFYIsN0Qe m9yGZ4mdjYDYL0HREOrnOjKrPbuxSPtIKV/AIMBPaKjJ/clzHw8J2PTe0DRARSqg6Usl ERCw== X-Forwarded-Encrypted: i=1; AHgh+RrXpHGyf/PEoKhwtam7le+bi6JhOozZNtXkbmFnfgXUyRtYYNUPo068/vPHjTCNT0ihqGu9/JEqQ9iz3Eo=@vger.kernel.org X-Gm-Message-State: AOJu0Yyqw1dJ2NVLGjZXG3Wr3U4c/LbTpHz5goKTggJLElY981aLDzUH 8Bw5GPWEP8wiFjvcyOjjDKXHRqG7/Bm6tzEYHUkb7YHWK0AmtT4Twbru X-Gm-Gg: AR+sD11MOPVjUAGxU09kmOVgftpDEsSUBX2B9GsQXFmQWSRGRc+PIG7L2uaVFSLoRNy a1Ebt0vDcSBEFmT/2OCUgfhBSBJGsBc6RrdEdbwRL3ed8ixYubp4gI6Ph7RGrGCiyikJU3ZTVVj 5izWwqWyvszMkjx6RKjDfNcqZSZwSlacfMmMhUmbctDxvWIrbES7VakfrQrBgeYbASY3iessZ6X 6po+TrDZme0TTgw1sfhse/8t7jYzT/IqlgBivLlymZMUG64+ilnkRK9l1HYNaDJRFwcR3nVx8Ls KJT1W85ZDyzHf+ufo16kBPv8rjIKbuEA7hSbcSfYHvaIzdf4zueo6RnPo6u8OTcU80rvaBNZUqv I8J3Vzs6NytmUqdtXw36I3Bs4zMPDK779J5mRWuYmj4nt4yXElK9jIEHZQJirVfITWbHAyaGkID vcvyUsEdX/6w/LGeq5aIu9w629chthVKkVog+OnfGYk/sAEUsHuPpci8+SZoo= X-Received: by 2002:a17:906:9f8e:b0:c19:5572:d234 with SMTP id a640c23a62f3a-c246a4ac801mr365162866b.1.1787282068936; Thu, 20 Aug 2026 20:14:28 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c24589e1b0csm241069366b.8.2026.08.20.20.14.28 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Aug 2026 20:14:28 -0700 (PDT) Date: Fri, 21 Aug 2026 03:14:27 +0000 From: Wei Yang To: Yuan Liu Cc: David Hildenbrand , Oscar Salvador , Mike Rapoport , Wei Yang , linux-mm@kvack.org, Nanhai Zou , Chen Zhang , Jason Zeng , Chen Yu , Pan Deng , Tianyou Li , linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 1/2] mm/memory_hotplug: make shrink_zone_span() more robust Message-ID: <20260821031427.qq6mb3j2zqtzdl3n@master> Reply-To: Wei Yang References: <20260818085702.3395529-1-yuan1.liu@intel.com> <20260818085702.3395529-2-yuan1.liu@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260818085702.3395529-2-yuan1.liu@intel.com> User-Agent: NeoMutt/20170113 (1.7.2) On Tue, Aug 18, 2026 at 04:57:01AM -0400, Yuan Liu wrote: >From: "David Hildenbrand (Arm)" > >Let's make shrink_zone_span() more robust by checking in >find_smallest_section_pfn() / find_biggest_section_pfn() that the >start and end PFNs of the subsection are within the zone. > >While at it, clean up the function by factoring the core check out >into subsection_overlaps_zone(). > >There likely is no need to check the nid first. We require >SPARSEMEM_VMEMMAP_ENABLE, where pfn_to_page() is cheap, and >pfn_to_nid() on CONFIG_NUMA would call pfn_to_page() either way. >So let's just drop that for now. > >Signed-off-by: David Hildenbrand (Arm) >Tested-by: Yuan Liu >Signed-off-by: Yuan Liu >--- > mm/memory_hotplug.c | 59 ++++++++++++++++++--------------------------- > 1 file changed, 24 insertions(+), 35 deletions(-) > >diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c >index 7ac19fab2263..cd82e79f0782 100644 >--- a/mm/memory_hotplug.c >+++ b/mm/memory_hotplug.c >@@ -422,49 +422,39 @@ int __add_pages(int nid, unsigned long pfn, unsigned long nr_pages, > return err; > } > >-/* find the smallest valid pfn in the range [start_pfn, end_pfn) */ >-static unsigned long find_smallest_section_pfn(int nid, struct zone *zone, >- unsigned long start_pfn, >- unsigned long end_pfn) >+static bool subsection_overlaps_zone(unsigned long pfn, struct zone *zone) > { >- for (; start_pfn < end_pfn; start_pfn += PAGES_PER_SUBSECTION) { >- if (unlikely(!pfn_to_online_page(start_pfn))) >- continue; >+ const unsigned long start_pfn = ALIGN_DOWN(pfn, PAGES_PER_SUBSECTION); >+ const unsigned long end_pfn = start_pfn + PAGES_PER_SUBSECTION - 1; > >- if (unlikely(pfn_to_nid(start_pfn) != nid)) >- continue; Would we have a memory layout with node interleave? -- Wei Yang Help you, Help me