RE: [PATCH] mm/memory hotplug/unplug: Optimize zone contiguous check when changing pfn range
From: Liu, Yuan1
Date: Fri Mar 27 2026 - 03:47:01 EST
> -----Original Message-----
> From: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> Sent: Thursday, March 26, 2026 5:23 PM
> To: Liu, Yuan1 <yuan1.liu@xxxxxxxxx>; Oscar Salvador <osalvador@xxxxxxx>;
> Mike Rapoport <rppt@xxxxxxxxxx>; Wei Yang <richard.weiyang@xxxxxxxxx>
> Cc: linux-mm@xxxxxxxxx; Hu, Yong <yong.hu@xxxxxxxxx>; Zou, Nanhai
> <nanhai.zou@xxxxxxxxx>; Tim Chen <tim.c.chen@xxxxxxxxxxxxxxx>; Zhuo, Qiuxu
> <qiuxu.zhuo@xxxxxxxxx>; Chen, Yu C <yu.c.chen@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
>
>
> > About AI feedback below
> >
> > init_unavailable_range() uses for_each_valid_pfn() and skips unmapped
> > sections that lack a mem_map. If the full hole size is added anyway,
> > pages_with_online_memmap could artificially match spanned_pages for
> > zones with missing sections.
> >
> > Could this make zone_is_contiguous() incorrectly return true, bypassing
> > pfn_valid() checks and potentially dereferencing missing sections?
> > unsinged long zone_hole_pages
> >
> > I think if I can update the pages_with_online_memmap in the
> > init_unavailable_range directly.
>
> See how I handled it: I simply return the number of initialized pages
> from the function. I think that should do.
Yes, I will follow that and thanks for your comments.
> --
> Cheers,
>
> David