From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (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 E49452D0602 for ; Thu, 23 Apr 2026 02:15:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776910505; cv=none; b=effmOzlOAbPM71AQ7r1IoZ7GQXHYXyCtHSE4pPVjIcxGdLV+7Lkc7JCVzLzHmofqH23jcvbUNI3LcmA31vWqHf3s2U3T5eLqgGiKErjz0ekSduEWAnfOHjpgcQCBjZi10lDxnMaF5Y13MMFiVltrnmmw38bPSozbTqyuwYjANCE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776910505; c=relaxed/simple; bh=JJtB98NlEf0V0CZ6C2hJk0K7tNaOzH38skeQBdUmGhE=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=j8Rf2oE6KDoXe1u4tScWsQ8JtWKgL0KIz+6VkN7rJ7jEnUXgycJV3U1M2v82qxRUoIr6fJ4W7fUXTHQCWncovTMb3vTdzGgtK8A0MVNPo7cH49vaUVZctesPP/rYAMuCrCn/EutGmJXuk0SEekMDnyTeCpkOzkjHO3BGveez+EQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ba9Y5yxV; arc=none smtp.client-ip=95.215.58.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ba9Y5yxV" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1776910501; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n0/01H4xiCJnfs36bIwGAXpJVzm4AGBrMPoyje3Rvz4=; b=ba9Y5yxVcom61fXlDbNnPGxckX72Wg1DbZmfHjnu0lMfj/YISK/8hzvjV9zBBmkDvDlXmc SbmfdF/oUXqzKRiVmBSDlEqxaH+CHmnwrQ4CWf04UEYAcEGyU3JbHjLzN4e806O8Lolewg chajDmzvd9vVnRWQ7EpP9ylApOsyss0= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.500.181\)) Subject: Re: [PATCH v4 2/5] mm/sparse-vmemmap: Pass @pgmap argument to memory deactivation paths X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: Date: Thu, 23 Apr 2026 10:14:16 +0800 Cc: Muchun Song , Andrew Morton , Oscar Salvador , Michael Ellerman , Madhavan Srinivasan , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Nicholas Piggin , Christophe Leroy , aneesh.kumar@linux.ibm.com, joao.m.martins@oracle.com, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <3745D308-DF29-477C-A25F-CDA63400D5ED@linux.dev> References: <20260422081420.4009847-1-songmuchun@bytedance.com> <20260422081420.4009847-3-songmuchun@bytedance.com> To: "David Hildenbrand (Arm)" X-Migadu-Flow: FLOW_OUT > On Apr 23, 2026, at 02:50, David Hildenbrand (Arm) = wrote: >=20 > On 4/22/26 10:14, Muchun Song wrote: >> Currently, the memory hot-remove call chain -- arch_remove_memory(), >> __remove_pages(), sparse_remove_section() and section_deactivate() -- >> does not carry the struct dev_pagemap pointer. This prevents the = lower >> levels from knowing whether the section was originally populated with >> vmemmap optimizations (e.g., DAX with vmemmap optimization enabled). >>=20 >> Without this information, we cannot call vmemmap_can_optimize() to >> determine if the vmemmap pages were optimized. As a result, the = vmemmap >> page accounting during teardown will mistakenly assume a = non-optimized >> allocation, leading to incorrect memmap statistics. >>=20 >> To lay the groundwork for fixing the vmemmap page accounting, we need >> to pass the @pgmap pointer down to the deactivation location. Plumb = the >> @pgmap argument through the APIs of arch_remove_memory(), = __remove_pages() >> and sparse_remove_section(), mirroring the corresponding *_activate() >> paths. >>=20 >> Signed-off-by: Muchun Song >> Acked-by: Mike Rapoport (Microsoft) >> Reviewed-by: Oscar Salvador >=20 >=20 > [...] >=20 >> static void depopulate_section_memmap(unsigned long pfn, unsigned = long nr_pages, >> - struct vmem_altmap *altmap) >> + struct vmem_altmap *altmap, struct dev_pagemap *pgmap) >> { >> unsigned long start =3D (unsigned long) pfn_to_page(pfn); >> unsigned long end =3D start + nr_pages * sizeof(struct page); >> @@ -746,7 +746,7 @@ static int fill_subsection_map(unsigned long pfn, = unsigned long nr_pages) >> * usage map, but still need to free the vmemmap range. >> */ >> static void section_deactivate(unsigned long pfn, unsigned long = nr_pages, >> - struct vmem_altmap *altmap) >> + struct vmem_altmap *altmap, struct dev_pagemap *pgmap) >> { >> struct mem_section *ms =3D __pfn_to_section(pfn); >> bool section_is_early =3D early_section(ms); >> @@ -784,7 +784,7 @@ static void section_deactivate(unsigned long pfn, = unsigned long nr_pages, >> * section_activate() and pfn_valid() . >> */ >> if (!section_is_early) >> - depopulate_section_memmap(pfn, nr_pages, altmap); >> + depopulate_section_memmap(pfn, nr_pages, altmap, pgmap); >> else if (memmap) >> free_map_bootmem(memmap); >>=20 >> @@ -828,7 +828,7 @@ static struct page * __meminit = section_activate(int nid, unsigned long pfn, >>=20 >> memmap =3D populate_section_memmap(pfn, nr_pages, nid, altmap, = pgmap); >> if (!memmap) { >> - section_deactivate(pfn, nr_pages, altmap); >> + section_deactivate(pfn, nr_pages, altmap, pgmap); >> return ERR_PTR(-ENOMEM); >> } >>=20 >> @@ -889,13 +889,13 @@ int __meminit sparse_add_section(int nid, = unsigned long start_pfn, >> } >>=20 >> void sparse_remove_section(unsigned long pfn, unsigned long nr_pages, >> - struct vmem_altmap *altmap) >> + struct vmem_altmap *altmap, struct = dev_pagemap *pgmap) >=20 > While at it, could switch to two-tab indent here as well. OK. >=20 > Acked-by: David Hildenbrand (Arm) Thanks. Muchun. >=20 > --=20 > Cheers, >=20 > David