RE: [PATCH] mm/memory hotplug/unplug: Optimize zone contiguous check when changing pfn range
From: Liu, Yuan1
Date: Fri Mar 27 2026 - 03:50:19 EST
> -----Original Message-----
> From: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> Sent: Thursday, March 26, 2026 5:54 PM
> To: Chen, Yu C <yu.c.chen@xxxxxxxxx>; Liu, Yuan1 <yuan1.liu@xxxxxxxxx>;
> Mike Rapoport <rppt@xxxxxxxxxx>
> Cc: Oscar Salvador <osalvador@xxxxxxx>; Wei Yang
> <richard.weiyang@xxxxxxxxx>; linux-mm@xxxxxxxxx; Hu, Yong
> <yong.hu@xxxxxxxxx>; Zou, Nanhai <nanhai.zou@xxxxxxxxx>; Tim Chen
> <tim.c.chen@xxxxxxxxxxxxxxx>; Zhuo, Qiuxu <qiuxu.zhuo@xxxxxxxxx>; Deng,
> Pan <pan.deng@xxxxxxxxx>; Li, Tianyou <tianyou.li@xxxxxxxxx>; Chen Zhang
> <zhangchen.kidd@xxxxxx>; linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH] mm/memory hotplug/unplug: Optimize zone contiguous
> check when changing pfn range
>
> On 3/26/26 08:38, Chen, Yu C wrote:
> > On 3/26/2026 3:30 PM, Liu, Yuan1 wrote:
> >>> -----Original Message-----
> >
> > [ .... ]
> >
> >>
> >> Btw, can we introduce a new kernel command-line parameter to allow
> >> users to select
> >> the memory block size? This could also address the current issue.
> >>
> >> Test Results as below, memory block size 128MB Vs. 2GB
> >> +----------------+------+---------------+--------------+---------------
> -+
> >> | | Size | 128MG | 2GB | Time Reduction
> |
> >> | +------+---------------+--------------+---------------
> -+
> >> | Plug Memory | 256G
> | 10s | 3s | 70% |
> >> | +------+---------------+--------------+---------------
> -+
> >> | | 512G
> | 36s | 7s | 81% |
> >> +----------------+------+---------------+--------------+---------------
> -+
> >> +----------------+------+---------------+--------------
> >> +----------------+
> >> | | Size | 128MG | 2GB | Time Reduction
> |
> >> | +------+---------------+--------------+---------------
> -+
> >> | Unplug Memory | 256G
> | 11s | 3s | 72% |
> >> | +------+---------------+--------------+---------------
> -+
> >> | | 512G
> | 36s | 7s | 81% |
> >> +----------------+------+---------------+--------------+---------------
> -+
> >>
> >> And I see the UV system has already this (Kernel parameter is
> >> uv_memblksize).
> >> I think if we can introduce a common kernel parameter for memory block
> >> size configuration?
> >>
> >
> > Is it possible to turn uv_memblksize into a generic commandline
> > memblksize without
> > introducing extra parameter?
>
> We don't want that, and it's kind of a workaround for the problem. :)
> I think we would want to only account pages towards
> pages_with_online_memmap that fall within the zone span.
> We will not account pages initialized that are outside the zone span.
>
> Growing the zone and later trying to shrink them will only possibly see
> a "too small" pages_with_online_memmap value. That is fine, it simply
> prevents detecting "contiguous" so it's safe.
>
> We can document that, and in the future we could handle it a bit nicer
> (e.g., indicate these pages as being just fill material).
>
> So indeed, I guess we want to teach init_unavailable_range() to only
> account towards zone->pages_with_online_memmap whatever falls into the
> zone span.
>
> That could be done internally, or from the callers by calling
> init_unavailable_range() once for the out-of-zone range and once for the
> in-zone-range.
This looks like a clear approach, I will implement it in the next version.
> --
> Cheers,
>
> David