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 3E21825CC6C for ; Tue, 27 Jan 2026 07:10:24 +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=1769497825; cv=none; b=t2DrDzK+fVuMSt3A1n+W8png7/zoGt85ED2ZaWUyVDl67nXV43O3p+aGvCfzz6099ECVs990nqLPV6pQHKLQGCd/6iQ7jUOgDPOO9MJEIzAb8BlHTfD+AuDx04hbb1VWDWZfWy5YIGQsuM9LE3znRjnN4q/TaxrdY1k2kCZVTG8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769497825; c=relaxed/simple; bh=cf47isSmYP/qJ96nAoYSlmLKb5vr8p7KFIfjgd9LveU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bsvHVC/9tppsckU6+4h5fWLolu/EIJHPo1wONvhtCahb5Bg6NIjd8UNB3I9nnI8CcP032CLzR/7a0UXgPeYVr9mn9ppY8YJYhzYi5Xeqac+mXnGxGjEr3oE97mwv7lWfk+zs0wgNGcQkTiyT2jcTofjeZW8vgBpGoGTwlDdTzhI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sPTXoRAU; 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="sPTXoRAU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D76B8C116C6; Tue, 27 Jan 2026 07:10:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769497824; bh=cf47isSmYP/qJ96nAoYSlmLKb5vr8p7KFIfjgd9LveU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sPTXoRAUZy7+5HMmKMBg7oSDx64qfa2bYEEcRd1o/4Rk20ewPDlkj8ugKo6nycHZv LG6LJWVSVw8nme8XzLP5CNSpb/oDtkNZvc7+JBFo2DSXs7d8gdkkhGK9+UZxOb2SW9 IwcJavRooCZYjp4ma7NgJozCm0ultg3bLazNEc5LXy9otDU9MGBCdMh1B64FUO8dqM UIh4fdAuoO9azteRUa7wIMQHR0OEYfKFFg7USkJBD3ZQpFUB5JPAsXvEO6i+WJWwCS 6jP15uCkjKqLjlpVwHJVQ6xFWw1lwN9Eiw+/QSa8p+QLmdAZJBBFfjq8NMqVK6tTyU GDPIqWXYSdYhw== Date: Tue, 27 Jan 2026 09:10:16 +0200 From: Mike Rapoport To: "Li, Tianyou" 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 3/3] mm/memory hotplug/unplug: Optimize zone->contiguous update when changes pfn range Message-ID: References: <20260120143346.1427837-1-tianyou.li@intel.com> <20260120143346.1427837-4-tianyou.li@intel.com> <0f679956-fd29-4165-a136-18f68e517fb5@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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0f679956-fd29-4165-a136-18f68e517fb5@intel.com> Hi, On Sat, Jan 24, 2026 at 08:43:51PM +0800, Li, Tianyou wrote: > On 1/22/2026 7:43 PM, Mike Rapoport wrote: > > > > +int online_memory_block_pages(unsigned long start_pfn, unsigned long nr_pages, > > > + unsigned long nr_vmemmap_pages, struct zone *zone, > > > + struct memory_group *group) > > > { > > > + const bool contiguous = zone->contiguous; > > > + enum zone_contig_state new_contiguous_state; > > > int ret; > > > + /* > > > + * Calculate the new zone contig state before move_pfn_range_to_zone() > > > + * sets the zone temporarily to non-contiguous. > > > + */ > > > + new_contiguous_state = zone_contig_state_after_growing(zone, start_pfn, > > > + nr_pages); > > > + > > > if (nr_vmemmap_pages) { > > > ret = mhp_init_memmap_on_memory(start_pfn, nr_vmemmap_pages, zone); > > > if (ret) > > > - return ret; > > > + goto restore_zone_contig; > > But zone_contig_state_after_growing() does not change zone->contiguous. Why > > do we need to save and restore it? > > Move_pfn_range_to_zone() will clear the zone contiguous state and it was > invoked by online_pages(). If error occurs after > move_pfn_range_to_zone() called like in online_pages(), I think we'd better > to restore the original value if previous zone contiguous state is true. But after move_pfn_range_to_zone() the added pages are still offline, so I think the zone remains contiguous and the call to clear_zone_contiguous(zone) should not be there. BTW, as we have set_zone_contiguous(ZONE_CONTIG_NO) I think we can use it instead if clear_zone_contiguous() and remove the latter. -- Sincerely yours, Mike.