[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aXIK55fQeKfB-jM0@kernel.org>
Date: Thu, 22 Jan 2026 13:32:55 +0200
From: Mike Rapoport <rppt@...nel.org>
To: Tianyou Li <tianyou.li@...el.com>
Cc: David Hildenbrand <david@...nel.org>,
Oscar Salvador <osalvador@...e.de>,
Wei Yang <richard.weiyang@...il.com>,
Michal Hocko <mhocko@...e.com>, linux-mm@...ck.org,
Yong Hu <yong.hu@...el.com>, Nanhai Zou <nanhai.zou@...el.com>,
Yuan Liu <yuan1.liu@...el.com>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Qiuxu Zhuo <qiuxu.zhuo@...el.com>, Yu C Chen <yu.c.chen@...el.com>,
Pan Deng <pan.deng@...el.com>, Chen Zhang <zhangchen.kidd@...com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v8 2/3] mm/memory hotplug/unplug: Add
online_memory_block_pages() and offline_memory_block_pages()
Hi,
On Tue, Jan 20, 2026 at 10:33:45PM +0800, Tianyou Li wrote:
> Encapsulate the mhp_init_memmap_on_memory() and online_pages() into
> online_memory_block_pages(). Thus we can further optimize the
> set_zone_contiguous() to check the whole memory block range, instead
> of check the zone contiguous in separate range.
>
> Correspondingly, encapsulate the mhp_deinit_memmap_on_memory() and
> offline_pages() into offline_memory_block_pages().
>
> Tested-by: Yuan Liu <yuan1.liu@...el.com>
> Reviewed-by: Yuan Liu <yuan1.liu@...el.com>
> Signed-off-by: Tianyou Li <tianyou.li@...el.com>
> ---
> drivers/base/memory.c | 53 ++++++---------------------
> include/linux/memory_hotplug.h | 18 +++++-----
> mm/memory_hotplug.c | 65 +++++++++++++++++++++++++++++++---
> 3 files changed, 80 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/base/memory.c b/drivers/base/memory.c
> index 751f248ca4a8..ea4d6fbf34fd 100644
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -246,31 +246,12 @@ static int memory_block_online(struct memory_block *mem)
> nr_vmemmap_pages = mem->altmap->free;
>
> mem_hotplug_begin();
> - if (nr_vmemmap_pages) {
> - ret = mhp_init_memmap_on_memory(start_pfn, nr_vmemmap_pages, zone);
> - if (ret)
> - goto out;
> - }
> -
> - ret = online_pages(start_pfn + nr_vmemmap_pages,
> - nr_pages - nr_vmemmap_pages, zone, mem->group);
> - if (ret) {
> - if (nr_vmemmap_pages)
> - mhp_deinit_memmap_on_memory(start_pfn, nr_vmemmap_pages);
> - goto out;
> - }
> -
> - /*
> - * Account once onlining succeeded. If the zone was unpopulated, it is
> - * now already properly populated.
> - */
> - if (nr_vmemmap_pages)
> - adjust_present_page_count(pfn_to_page(start_pfn), mem->group,
> - nr_vmemmap_pages);
> -
> - mem->zone = zone;
> -out:
> + ret = online_memory_block_pages(start_pfn, nr_pages, nr_vmemmap_pages,
> + zone, mem->group);
> + if (!ret)
> + mem->zone = zone;
I think we can move most of memory_block_online() to the new function and
pass struct memory_block to it.
I'd suggest
int mhp_block_online(struct memory_block *block)
and
int mhp_block_offline(struct memory_block *block)
Other than that LGTM.
> mem_hotplug_done();
> +
> return ret;
> }
>
--
Sincerely yours,
Mike.
Powered by blists - more mailing lists