[PATCH v4 0/2] mm/memory hotplug/unplug: Optimize zone contiguous check when changing pfn range

Yuan Liu posted 2 patches 1 month, 3 weeks ago
Documentation/mm/physical_memory.rst | 13 +++++
drivers/base/memory.c                |  6 ++
include/linux/mmzone.h               | 47 ++++++++++++++++
mm/internal.h                        |  8 +--
mm/memory_hotplug.c                  | 12 +---
mm/mm_init.c                         | 82 +++++++++++-----------------
6 files changed, 100 insertions(+), 68 deletions(-)
[PATCH v4 0/2] mm/memory hotplug/unplug: Optimize zone contiguous check when changing pfn range
Posted by Yuan Liu 1 month, 3 weeks ago
This series cleans up the overlap memory map init check and
optimizes zone contiguous check when changing pfn range.

In addition to providing a significant improvement for VM hotplug
(see the second patch for reference), it brings benefits for CXL
hotplug as well. The link is as follows
https://lore.kernel.org/all/20260409023552.GA2807@AE/

v3 link:
    https://lore.kernel.org/all/20260408031615.1831922-1-yuan1.liu@intel.com/

v4 changes:
    Add a new patch for clean up overlap memory map init check

Yuan Liu (2):
  mm: move overlap memory map init check to memmap_init()
  mm/memory hotplug/unplug: Optimize zone contiguous check when changing
    pfn range

 Documentation/mm/physical_memory.rst | 13 +++++
 drivers/base/memory.c                |  6 ++
 include/linux/mmzone.h               | 47 ++++++++++++++++
 mm/internal.h                        |  8 +--
 mm/memory_hotplug.c                  | 12 +---
 mm/mm_init.c                         | 82 +++++++++++-----------------
 6 files changed, 100 insertions(+), 68 deletions(-)

-- 
2.47.3
Re: [PATCH v4 0/2] mm/memory hotplug/unplug: Optimize zone contiguous check when changing pfn range
Posted by David Hildenbrand (Arm) 1 month, 2 weeks ago
On 4/21/26 14:55, Yuan Liu wrote:
> This series cleans up the overlap memory map init check and
> optimizes zone contiguous check when changing pfn range.
> 
> In addition to providing a significant improvement for VM hotplug
> (see the second patch for reference), it brings benefits for CXL
> hotplug as well. The link is as follows
> https://lore.kernel.org/all/20260409023552.GA2807@AE/
> 
> v3 link:
>     https://lore.kernel.org/all/20260408031615.1831922-1-yuan1.liu@intel.com/
> 
> v4 changes:
>     Add a new patch for clean up overlap memory map init check

Didn't you also wanted to add a patch to improve shrink_zone_span to check both
sides of the PAGES_PER_SUBSECTION block for fitting nid+zid?

-- 
Cheers,

David
RE: [PATCH v4 0/2] mm/memory hotplug/unplug: Optimize zone contiguous check when changing pfn range
Posted by Liu, Yuan1 1 month, 2 weeks ago
> -----Original Message-----
> From: David Hildenbrand (Arm) <david@kernel.org>
> Sent: Wednesday, April 22, 2026 3:47 PM
> To: Liu, Yuan1 <yuan1.liu@intel.com>; Oscar Salvador <osalvador@suse.de>;
> Mike Rapoport <rppt@kernel.org>; Wei Yang <richard.weiyang@gmail.com>
> Cc: linux-mm@kvack.org; Hu, Yong <yong.hu@intel.com>; Zou, Nanhai
> <nanhai.zou@intel.com>; Tim Chen <tim.c.chen@linux.intel.com>; Zhuo, Qiuxu
> <qiuxu.zhuo@intel.com>; Chen, Yu C <yu.c.chen@intel.com>; Deng, Pan
> <pan.deng@intel.com>; Li, Tianyou <tianyou.li@intel.com>; Chen Zhang
> <zhangchen.kidd@jd.com>; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v4 0/2] mm/memory hotplug/unplug: Optimize zone
> contiguous check when changing pfn range
> 
> On 4/21/26 14:55, Yuan Liu wrote:
> > This series cleans up the overlap memory map init check and
> > optimizes zone contiguous check when changing pfn range.
> >
> > In addition to providing a significant improvement for VM hotplug
> > (see the second patch for reference), it brings benefits for CXL
> > hotplug as well. The link is as follows
> > https://lore.kernel.org/all/20260409023552.GA2807@AE/
> >
> > v3 link:
> >     https://lore.kernel.org/all/20260408031615.1831922-1-
> yuan1.liu@intel.com/
> >
> > v4 changes:
> >     Add a new patch for clean up overlap memory map init check
> 
> Didn't you also wanted to add a patch to improve shrink_zone_span to check
> both
> sides of the PAGES_PER_SUBSECTION block for fitting nid+zid?

Hi David

My apologies for missing this. I will include it in the next version.
 
> --
> Cheers,
> 
> David
Re: [PATCH v4 0/2] mm/memory hotplug/unplug: Optimize zone contiguous check when changing pfn range
Posted by David Hildenbrand (Arm) 1 month, 2 weeks ago
On 4/22/26 09:56, Liu, Yuan1 wrote:
>> -----Original Message-----
>> From: David Hildenbrand (Arm) <david@kernel.org>
>> Sent: Wednesday, April 22, 2026 3:47 PM
>> To: Liu, Yuan1 <yuan1.liu@intel.com>; Oscar Salvador <osalvador@suse.de>;
>> Mike Rapoport <rppt@kernel.org>; Wei Yang <richard.weiyang@gmail.com>
>> Cc: linux-mm@kvack.org; Hu, Yong <yong.hu@intel.com>; Zou, Nanhai
>> <nanhai.zou@intel.com>; Tim Chen <tim.c.chen@linux.intel.com>; Zhuo, Qiuxu
>> <qiuxu.zhuo@intel.com>; Chen, Yu C <yu.c.chen@intel.com>; Deng, Pan
>> <pan.deng@intel.com>; Li, Tianyou <tianyou.li@intel.com>; Chen Zhang
>> <zhangchen.kidd@jd.com>; linux-kernel@vger.kernel.org
>> Subject: Re: [PATCH v4 0/2] mm/memory hotplug/unplug: Optimize zone
>> contiguous check when changing pfn range
>>
>> On 4/21/26 14:55, Yuan Liu wrote:
>>> This series cleans up the overlap memory map init check and
>>> optimizes zone contiguous check when changing pfn range.
>>>
>>> In addition to providing a significant improvement for VM hotplug
>>> (see the second patch for reference), it brings benefits for CXL
>>> hotplug as well. The link is as follows
>>> https://lore.kernel.org/all/20260409023552.GA2807@AE/
>>>
>>> v3 link:
>>>     https://lore.kernel.org/all/20260408031615.1831922-1-
>> yuan1.liu@intel.com/
>>>
>>> v4 changes:
>>>     Add a new patch for clean up overlap memory map init check
>>
>> Didn't you also wanted to add a patch to improve shrink_zone_span to check
>> both
>> sides of the PAGES_PER_SUBSECTION block for fitting nid+zid?
> 
> Hi David
> 
> My apologies for missing this. I will include it in the next version.

And isn't there also the problem with the subsection pfn_valid() handling etc
where I proposed a change?

-- 
Cheers,

David
RE: [PATCH v4 0/2] mm/memory hotplug/unplug: Optimize zone contiguous check when changing pfn range
Posted by Liu, Yuan1 1 month, 2 weeks ago
> -----Original Message-----
> From: David Hildenbrand (Arm) <david@kernel.org>
> Sent: Thursday, April 23, 2026 3:13 AM
> To: Liu, Yuan1 <yuan1.liu@intel.com>; Oscar Salvador <osalvador@suse.de>;
> Mike Rapoport <rppt@kernel.org>; Wei Yang <richard.weiyang@gmail.com>
> Cc: linux-mm@kvack.org; Hu, Yong <yong.hu@intel.com>; Zou, Nanhai
> <nanhai.zou@intel.com>; Tim Chen <tim.c.chen@linux.intel.com>; Zhuo, Qiuxu
> <qiuxu.zhuo@intel.com>; Chen, Yu C <yu.c.chen@intel.com>; Deng, Pan
> <pan.deng@intel.com>; Li, Tianyou <tianyou.li@intel.com>; Chen Zhang
> <zhangchen.kidd@jd.com>; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v4 0/2] mm/memory hotplug/unplug: Optimize zone
> contiguous check when changing pfn range
> 
> On 4/22/26 09:56, Liu, Yuan1 wrote:
> >> -----Original Message-----
> >> From: David Hildenbrand (Arm) <david@kernel.org>
> >> Sent: Wednesday, April 22, 2026 3:47 PM
> >> To: Liu, Yuan1 <yuan1.liu@intel.com>; Oscar Salvador
> <osalvador@suse.de>;
> >> Mike Rapoport <rppt@kernel.org>; Wei Yang <richard.weiyang@gmail.com>
> >> Cc: linux-mm@kvack.org; Hu, Yong <yong.hu@intel.com>; Zou, Nanhai
> >> <nanhai.zou@intel.com>; Tim Chen <tim.c.chen@linux.intel.com>; Zhuo,
> Qiuxu
> >> <qiuxu.zhuo@intel.com>; Chen, Yu C <yu.c.chen@intel.com>; Deng, Pan
> >> <pan.deng@intel.com>; Li, Tianyou <tianyou.li@intel.com>; Chen Zhang
> >> <zhangchen.kidd@jd.com>; linux-kernel@vger.kernel.org
> >> Subject: Re: [PATCH v4 0/2] mm/memory hotplug/unplug: Optimize zone
> >> contiguous check when changing pfn range
> >>
> >> On 4/21/26 14:55, Yuan Liu wrote:
> >>> This series cleans up the overlap memory map init check and
> >>> optimizes zone contiguous check when changing pfn range.
> >>>
> >>> In addition to providing a significant improvement for VM hotplug
> >>> (see the second patch for reference), it brings benefits for CXL
> >>> hotplug as well. The link is as follows
> >>> https://lore.kernel.org/all/20260409023552.GA2807@AE/
> >>>
> >>> v3 link:
> >>>     https://lore.kernel.org/all/20260408031615.1831922-1-
> >> yuan1.liu@intel.com/
> >>>
> >>> v4 changes:
> >>>     Add a new patch for clean up overlap memory map init check
> >>
> >> Didn't you also wanted to add a patch to improve shrink_zone_span to
> check
> >> both
> >> sides of the PAGES_PER_SUBSECTION block for fitting nid+zid?
> >
> > Hi David
> >
> > My apologies for missing this. I will include it in the next version.
> 
> And isn't there also the problem with the subsection pfn_valid() handling
> etc
> where I proposed a change?

Hi David

Sorry I didn’t catch your earlier discussion with Wei Yang. I’ve found your 
suggestion and implementation, and will split the pfn_valid/first_valid_pfn
changes into a separate patch for the next version.

For testing, I'll reproduce Wei Yang's setup (memblock_remove() of a
sub-section sized hole inside an early section) and confirm that
zone contiguous stays at 0, matching the behaviour before this series.

Thanks for the reminder, and thanks to Wei for the original report.

> --
> Cheers,
> 
> David