From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE19C32C31D for ; Tue, 27 Jan 2026 06:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769497133; cv=none; b=Xc+7nfcw5PenlQKHy/te7YBigLhKuxTHkFgwEeRq0lPm34NoVnUIeC2xIVyyLWj4CCzA9kzUyGZRp9MVTIfMUORyV3zVUh5ZKILo/PVUdhp9tplDarymxPZoxLL3WwHuXENqeUPP5gQ8/NX9KT3th68m9JaMzqierognMt5Q90c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769497133; c=relaxed/simple; bh=k6dfEQf49JWtiO8s+3goGp6rxKKI+aKNiywZpo38Cyg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pzKgXIrfZ+ck32bDukri0CI+/wjKBlPzT9OlgwVCN2OfSTqO1GDi/XC1QAw1G+KL2H4bgU6iPp7b8VbSmsldl2afFQ1z/CIyyFvxw7HWbsmesBgLIMst7TeLDK7cL7yS6+sWxQYh5IDnepTPmiJSQT/utaQKwEizPzzhyxgmc9Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cWIP8VPG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cWIP8VPG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5ACCBC116C6; Tue, 27 Jan 2026 06:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769497133; bh=k6dfEQf49JWtiO8s+3goGp6rxKKI+aKNiywZpo38Cyg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cWIP8VPGVhlGZeBl3t6fbSrKKmLY4Fy6gEBQ6kH36mDf+3V/4yKIBZ4J83GdGz9fd bdWk++BnElexxDDqgfl70DoYHcO90NEu7JmQ7uWtD0lDg3KHUX+x2aAJuCF+DPf07Y pTu5ywcjspOmabUwJqOafVS5AacjEmLgYcQdRoKQPjoRUdDOZfKoUUp1xorA+oONjT ZnVz3PLO7t/teYcndZ+0BlFLyGhMBy1XrXMXjOQc/iawTmtNGONDLGQsQ4P69Brw57 EzY80qyrttpZjTOLh3YNB7OlJOXqO2cc9L+Pan0zS7b4l2hIYC/nF/zZkEJu1/MYJp 7omJbUjTmEeyg== Date: Tue, 27 Jan 2026 08:58:44 +0200 From: Mike Rapoport To: "Li, Tianyou" Cc: David Hildenbrand , Oscar Salvador , Wei Yang , Michal Hocko , linux-mm@kvack.org, Yong Hu , Nanhai Zou , Yuan Liu , Tim Chen , Qiuxu Zhuo , Yu C Chen , Pan Deng , Chen Zhang , linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 2/3] mm/memory hotplug/unplug: Add online_memory_block_pages() and offline_memory_block_pages() Message-ID: References: <20260120143346.1427837-1-tianyou.li@intel.com> <20260120143346.1427837-3-tianyou.li@intel.com> <705d63f7-2451-46bc-b1f0-bef718b82283@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <705d63f7-2451-46bc-b1f0-bef718b82283@intel.com> On Sat, Jan 24, 2026 at 08:30:57PM +0800, Li, Tianyou wrote: > > On 1/22/2026 7:32 PM, Mike Rapoport wrote: > > > 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. > > > It's doable, if not other comments I can change the code. Would it look like > moving the functions to mm/memory_hotplug.c, change the name to > mhp_block_online() and mhp_block_offline(), and change the references where > the original function invoked in drivers/base/memory.c? Yeah, that's what I thought about. Even more broadly, I think the functionality in drivers/base/memory.c belongs to mm/ much more than to drivers/ but that's surely out of scope for these patches. > My prior thoughts on this was just break the code as small pieces as > necessary to handle the pages online part together with zone contiguous > state update. IMHO moving the entire function is cleaner, let's hear what David and Oscar think. -- Sincerely yours, Mike.