linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Li, Tianyou" <tianyou.li@intel.com>
To: Mike Rapoport <rppt@kernel.org>
Cc: David Hildenbrand <david@kernel.org>,
	Oscar Salvador <osalvador@suse.de>,
	Wei Yang <richard.weiyang@gmail.com>,
	Michal Hocko <mhocko@suse.com>, <linux-mm@kvack.org>,
	Yong Hu <yong.hu@intel.com>, Nanhai Zou <nanhai.zou@intel.com>,
	Yuan Liu <yuan1.liu@intel.com>,
	Tim Chen <tim.c.chen@linux.intel.com>,
	Qiuxu Zhuo <qiuxu.zhuo@intel.com>,
	Yu C Chen <yu.c.chen@intel.com>, Pan Deng <pan.deng@intel.com>,
	Chen Zhang <zhangchen.kidd@jd.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v8 3/3] mm/memory hotplug/unplug: Optimize zone->contiguous update when changes pfn range
Date: Wed, 28 Jan 2026 22:11:47 +0800	[thread overview]
Message-ID: <0c649fb2-cbcc-48a8-8d6d-9d7f8a58858d@intel.com> (raw)
In-Reply-To: <aXhk2F3gSXHnCo5s@kernel.org>


On 1/27/2026 3:10 PM, Mike Rapoport wrote:
> 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.

Since move_pfn_range_to_zone() may change the zone contiguous state, 
clear_zone_contiguous() should be invoked. If we did not 
clear_zone_contiguous() properly, especially keep the zone contiguous 
state as true but actually the zone is non contiguous after resize the 
zone, the code path rely on the contiguous state potentially may fail?

I am not sure if we need to handle the clear_zone_contiguous() in or out 
of move_pfn_range_to_zone() in this patch series.

> 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.
>   

Yes we can. I am hesitate to do so because clear_zone_contiguous() has a 
name that explain itself. The pair of clear/set seems a pattern should 
be preserved? I am OK to change the code, let's hear from other comments 
if feasible? Thanks.


Regards,

Tianyou



      reply	other threads:[~2026-01-28 14:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-20 14:33 [PATCH v8 0/3] Optimize zone->contiguous update and issue fix Tianyou Li
2026-01-20 14:33 ` [PATCH v8 1/3] mm/memory hotplug: Fix zone->contiguous always false when hotplug Tianyou Li
2026-01-22 11:16   ` Mike Rapoport
2026-01-24 12:18     ` Li, Tianyou
2026-01-26 21:58       ` Andrew Morton
2026-01-28 14:16         ` Li, Tianyou
2026-01-27  6:53       ` Mike Rapoport
2026-01-28 13:49         ` Li, Tianyou
2026-01-20 14:33 ` [PATCH v8 2/3] mm/memory hotplug/unplug: Add online_memory_block_pages() and offline_memory_block_pages() Tianyou Li
2026-01-22 11:32   ` Mike Rapoport
2026-01-24 12:30     ` Li, Tianyou
2026-01-27  6:58       ` Mike Rapoport
2026-01-28 13:56         ` Li, Tianyou
2026-01-20 14:33 ` [PATCH v8 3/3] mm/memory hotplug/unplug: Optimize zone->contiguous update when changes pfn range Tianyou Li
2026-01-22 11:43   ` Mike Rapoport
2026-01-24 12:43     ` Li, Tianyou
2026-01-27  7:10       ` Mike Rapoport
2026-01-28 14:11         ` Li, Tianyou [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0c649fb2-cbcc-48a8-8d6d-9d7f8a58858d@intel.com \
    --to=tianyou.li@intel.com \
    --cc=david@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=nanhai.zou@intel.com \
    --cc=osalvador@suse.de \
    --cc=pan.deng@intel.com \
    --cc=qiuxu.zhuo@intel.com \
    --cc=richard.weiyang@gmail.com \
    --cc=rppt@kernel.org \
    --cc=tim.c.chen@linux.intel.com \
    --cc=yong.hu@intel.com \
    --cc=yu.c.chen@intel.com \
    --cc=yuan1.liu@intel.com \
    --cc=zhangchen.kidd@jd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox