From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) (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 EF25A26ED37 for ; Tue, 14 Apr 2026 02:29:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776133760; cv=none; b=LZbDT9J5b3UmtAOS2t9bYtopMV3aznLquPCgK+m205GWA19aKsyMQpf7z3ycr/sEwAVRDr5kcCPplbyOm1UOvf9MYA4PVGc95j9T9GR/yt+Q7p6/Vzz2mZlnzTO3qdLiT4KAEo1SqpuV3R7KmeAI4/y6E9pMu7B+xQ1SUIRJA4o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776133760; c=relaxed/simple; bh=AsG74vm7+DPv7PI1t53WRMtcWnuCHOlDKJlH1PvkGg4=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=NxIARSwYiPwb7UtyfjFNed8+sWLxdcLSASpe+zVKEEnsG1/4eT9BpGEyFK7LZx5aZtu4Y06u1KiC2WvVzhD+V3xUYU5vrGrx+FcYbbin8Z/DBN51voE0dshb6eJ7S7arSE6aJyZ7VC8Hq9ShSkS3Eu8nVrjcki/A5ZBPJ3ICnBM= 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=Yd2bGA7z; arc=none smtp.client-ip=91.218.175.174 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="Yd2bGA7z" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1776133755; 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=V5QX9+pQg1ULyMnKqjfgXchOKAT14re8KJFOLZ7j1Uc=; b=Yd2bGA7z+vMWx2P0hf+Ov1gl4sMFJg6i7OJVdClj6OGD3ec4EqbxCfQ/5VoLn6XgtOKb83 nP3kyHV5sscI5E+Q1Vp55uKsfQ9jDr0m5aGN3876Obkur4sGjaZwHTpPHVRVlssBSo/Pqd gIRpkEbiM6gSw4IOlo+LHzPtvGNrYiE= 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 03/49] mm/sparse: fix vmemmap page accounting for HVOed DAX X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: Date: Tue, 14 Apr 2026 10:28:24 +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: References: <20260405125240.2558577-1-songmuchun@bytedance.com> <20260405125240.2558577-4-songmuchun@bytedance.com> To: "David Hildenbrand (Arm)" X-Migadu-Flow: FLOW_OUT > On Apr 14, 2026, at 02:39, David Hildenbrand (Arm) = wrote: >=20 > On 4/5/26 14:51, Muchun Song wrote: >> When HVO is enabled for DAX, the vmemmap page accounting is wrong = since >> it only accounts for non-HVO case. >>=20 >> Fix the accounting by introducing section_vmemmap_pages() that = returns >> the exact number of vmemmap pages needed for the given pfn range. >=20 > I guess only the accounting in /proc/meminfo is messed up, correct? No. It is in /proc/vmstat cat /proc/vmstat | grep memmap nr_memmap_pages 0 nr_memmap_boot_pages 2097163 >=20 >>=20 >> Fixes: 15995a352474 ("mm: report per-page metadata information") >=20 > Similarly, please send all fixes out separately. Will do in next version. >=20 >> Signed-off-by: Muchun Song >> --- >> mm/sparse-vmemmap.c | 30 ++++++++++++++++++++++++++---- >> 1 file changed, 26 insertions(+), 4 deletions(-) >>=20 >> diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c >> index 7aa9a97498eb..0ef96b1afbcc 100644 >> --- a/mm/sparse-vmemmap.c >> +++ b/mm/sparse-vmemmap.c >> @@ -724,6 +724,27 @@ static int fill_subsection_map(unsigned long = pfn, unsigned long nr_pages) >> return rc; >> } >>=20 >> +static int __meminit section_vmemmap_pages(unsigned long pfn, = unsigned long nr_pages, >> + struct vmem_altmap *altmap, struct dev_pagemap *pgmap) >> +{ >> + unsigned int order =3D pgmap ? pgmap->vmemmap_shift : 0; >> + unsigned long pages_per_compound =3D 1L << order; >> + >> + VM_BUG_ON(!IS_ALIGNED(pfn | nr_pages, min(pages_per_compound, = PAGES_PER_SECTION))); >> + VM_BUG_ON(pfn_to_section_nr(pfn) !=3D pfn_to_section_nr(pfn + = nr_pages - 1)); >=20 > No new VM_BUG_ON. Ever. :) >=20 > VM_WARN_ON_ONCE() is your friend. Got it. >=20 >> + >> + if (!vmemmap_can_optimize(altmap, pgmap)) >> + return DIV_ROUND_UP(nr_pages * sizeof(struct page), = PAGE_SIZE); >> + >> + if (order < PFN_SECTION_SHIFT) >> + return VMEMMAP_RESERVE_NR * nr_pages / = pages_per_compound; >> + >> + if (IS_ALIGNED(pfn, pages_per_compound)) >> + return VMEMMAP_RESERVE_NR; >> + >> + return 0; >> +} >> + >> /* >> * To deactivate a memory region, there are 3 cases to handle: >> * >> @@ -775,11 +796,12 @@ static void section_deactivate(unsigned long = pfn, unsigned long nr_pages, >> * section_activate() and pfn_valid() . >> */ >> if (!section_is_early) { >> - memmap_pages_add(-1L * (DIV_ROUND_UP(nr_pages * = sizeof(struct page), PAGE_SIZE))); >=20 > That's nice to be factored out in any case. >=20 > --=20 > Cheers, >=20 > David