From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3140222582 for ; Thu, 22 Jan 2026 11:16:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769080613; cv=none; b=Z3Hw7fLf4BdKXvyaYUTrUQBOdAiZc0bXcflbMkE/xTOD4HPuU0qPwungBDdlTGdbsMU9ihsqqWicqARCdFsjGJsqOpRMLUtPGdFeVKUPfqmYjtFW7iWPCOxojaUkOUWSzLICbwnukUlc5M1WQqLjoafMcMHJJc3qfORnfMS6QJo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769080613; c=relaxed/simple; bh=W/bJIzm3jSTgWiWcFxMKaaTTJUXpslY1VhhKcx5v7xI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=E3J7CF8D2DhgUCAtEEaDxtVlquNCXUkM16V2kz8KjoGjH9chIbJWO6NFJTAyexbC5uNhyi0lStI9O1+sw7NsnG1RS71PmoC0R9+cxC3S/u+ICQyvrfeI9cMw80Rayv350AtSXwSrQHoSHpZcWW/NqCKBYEVk3TUhDf9674I1D4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CUNYyx8c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CUNYyx8c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF819C116C6; Thu, 22 Jan 2026 11:16:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769080612; bh=W/bJIzm3jSTgWiWcFxMKaaTTJUXpslY1VhhKcx5v7xI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CUNYyx8cfhjh/ngKFyNusCJPTPD77D53HIlqiNow7NmMEDs2H5VvBVmHsIs5q/LR0 bcZjPt8xm/BTSKGHldQTRheQ006nnUjt7hTzvzfzWo/oCmx2cF9wV4kH2DV4fuVRrG Hmzg8QKxSGQ40xLg3O2HDHCMNFascA5AMl4LWF25igFMjWZCV9pPh1hOIBxpB/sGaR 0P4sPHo3eys1QoJE8GsyaIMjgjlhPEvFa3Xf8PodrRaZeQzAbwBf5FHtul70BgIj/y zzKkezo0d09mlIVbgU8EON7IajTYi1wE5omU/4qHOTWdEJl1u3KbsnbDyB5ehMo7pc oF2ygtkUhskGQ== Date: Thu, 22 Jan 2026 13:16:43 +0200 From: Mike Rapoport To: Tianyou Li Cc: David Hildenbrand , Oscar Salvador , Wei Yang , Michal Hocko , linux-mm@kvack.org, Yong Hu , Nanhai Zou , Yuan Liu , Tim Chen , Qiuxu Zhuo , Yu C Chen , Pan Deng , Chen Zhang , linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 1/3] mm/memory hotplug: Fix zone->contiguous always false when hotplug Message-ID: References: <20260120143346.1427837-1-tianyou.li@intel.com> <20260120143346.1427837-2-tianyou.li@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: <20260120143346.1427837-2-tianyou.li@intel.com> Hi, On Tue, Jan 20, 2026 at 10:33:44PM +0800, Tianyou Li wrote: > From: Yuan Liu > > set_zone_contiguous() uses __pageblock_pfn_to_page() to detect > pageblocks that either do not exist (hole) or that do not belong > to the same zone. > > __pageblock_pfn_to_page(), however, relies on pfn_to_online_page(), > effectively always returning NULL for memory ranges that were not > onlined yet. So when called on a range-to-be-onlined, it indicates > a memory hole to set_zone_contiguous(). > > Consequently, the set_zone_contiguous() call in move_pfn_range_to_zone(), > which happens early during memory onlining, will never detect a > zone as being contiguous. Bad. > > To fix the issue, move the set_zone_contiguous() call to a later > stage in memory onlining, where pfn_to_online_page() will succeed: > after we mark the memory sections to be online. > > Fixes: 2d070eab2e82 ("mm: consider zone which is not fully populated to have holes") cc stable@ perhaps? > Cc: Michal Hocko > Reviewed-by: Nanhai Zou > Signed-off-by: Yuan Liu > Signed-off-by: Tianyou Li > --- > mm/memory_hotplug.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index a63ec679d861..c8f492b5daf0 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -782,8 +782,6 @@ void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, > memmap_init_range(nr_pages, nid, zone_idx(zone), start_pfn, 0, > MEMINIT_HOTPLUG, altmap, migratetype, > isolate_pageblock); > - > - set_zone_contiguous(zone); move_pfn_range_to_zone() is also called from memremap::pagemap_range(). Shouldn't we add set_zone_contiguous() there as well? > } > > struct auto_movable_stats { > @@ -1205,6 +1203,13 @@ int online_pages(unsigned long pfn, unsigned long nr_pages, > } > > online_pages_range(pfn, nr_pages); > + > + /* > + * Now that the ranges are indicated as online, check whether the whole > + * zone is contiguous. > + */ > + set_zone_contiguous(zone); > + > adjust_present_page_count(pfn_to_page(pfn), group, nr_pages); > > if (node_arg.nid >= 0) > -- > 2.47.1 > -- Sincerely yours, Mike.