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 6356C37E2FD for ; Tue, 12 May 2026 15:22:16 +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=1778599336; cv=none; b=kHDpO5bd9TNfLKuaesDS8CsmDba+4rB+HutW0i5w35rEql0AoY6LJCqT4c77+p6LKMDxceROPAffAzgZrORVRnW9GawiEARbuzXz2xrCpd5+64QcNju0P2oD9goB/A/MWAdgM+8xUvASbqzqPJV9XRLjDBBEsSPNs91CltA0JS8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778599336; c=relaxed/simple; bh=0mQ9WUyf//P5pbvLH0sW41h1Dq7UtQ3QNXMnE8N+8AM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MMw1FYfkAg8vUZ4lJiJJA60pRxFl+K9CakCDtIEuLLnvWYpK8qhIBf3A5sHDTKXkvmO5A0DwKVDsYuauPihqB56lJDyri/w/hXFIGves2105HSDE4XayWOb7RFc9cD+IDY7tOsaXjox+icIXfnxGN64qtfMhpCf5FaNumnrN+c8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S8BrcVys; 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="S8BrcVys" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEB83C2BCB0; Tue, 12 May 2026 15:22:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778599336; bh=0mQ9WUyf//P5pbvLH0sW41h1Dq7UtQ3QNXMnE8N+8AM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=S8BrcVysnQowfGUpu+ooPgWJynKE//pAzW6sSO7hDvSasTPlNgaVqtfpUGhH851R2 WmHO7Xdgy9S+x2SWRJU3mYy0Hy9nhugcyvSv2ZftkS291MX/rYqeLqgiVjJl6qqA5V Eq9TR0XO5SGn1wb2tvYv9yzENhNHhw6GfogkwbcEzPHqBh1ZAj2HKKqW0A+9M5mdY4 aGgvW8eSC0BhkkvXQpo8t5ylz4xhWFpkgzWzL2dGJnCllyMlRYtwiSLmc4tzQ6gI3F QcrtlGWqCdUQ0ePPvZGqgeN3fC4LN/Fg4sp0x+IuvE86fQ5APeTOg7AXs7YER+3U5D UJYMiVWDvdgAw== Date: Tue, 12 May 2026 16:22:10 +0100 From: Will Deacon To: Yang Shi Cc: catalin.marinas@arm.com, ryan.roberts@arm.com, cl@gentwo.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [v6 PATCH] arm64: mm: show direct mapping use in /proc/meminfo Message-ID: References: <20260316192933.3993042-1-yang@os.amperecomputing.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: <20260316192933.3993042-1-yang@os.amperecomputing.com> On Mon, Mar 16, 2026 at 12:29:33PM -0700, Yang Shi wrote: > Since commit a166563e7ec3 ("arm64: mm: support large block mapping when > rodata=full"), the direct mapping may be split on some machines instead > keeping static since boot. It makes more sense to show the direct mapping > use in /proc/meminfo than before. > This patch will make /proc/meminfo show the direct mapping use like the > below (4K base page size): > DirectMap4K: 94792 kB > DirectMap64K: 134208 kB > DirectMap2M: 1173504 kB > DirectMap32M: 5636096 kB > DirectMap1G: 529530880 kB > > Although just the machines which support BBML2_NOABORT can split the > direct mapping, show it on all machines regardless of BBML2_NOABORT so > that the users have consistent view in order to avoid confusion. > > Although ptdump also can tell the direct map use, but it needs to dump > the whole kernel page table. It is costly and overkilling. It is also > in debugfs which may not be enabled by all distros. So showing direct > map use in /proc/meminfo seems more convenient and has less overhead. > > Signed-off-by: Yang Shi > --- > v6: * Rebased to v7.0-rc3 > * Rebased on top of Anshuman's v5 "arm64/mm: Enable batched TLB flush > in unmap_hotplug_range()" > * Used const for direct map type array per Will > * Defined PUD size for 16K/64K even though it is not used per Will > * Removed the misleading comment in init_pmd() per Will > v5: * Rebased to v6.19-rc4 > * Fixed the build error for !CONFIG_PROC_FS > v4: * Used PAGE_END instead of _PAGE_END(VA_BITS_MIN) per Ryan > * Used shorter name for the helpers and variables per Ryan > * Fixed accounting for memory hotunplug > v3: * Fixed the over-accounting problems per Ryan > * Introduced helpers for add/sub direct map use and #ifdef them with > CONFIG_PROC_FS per Ryan > * v3 is a fix patch on top of v2 > v2: * Counted in size instead of the number of entries per Ryan > * Removed shift array per Ryan > * Use lower case "k" per Ryan > * Fixed a couple of build warnings reported by kernel test robot > * Fixed a couple of poential miscounts > > arch/arm64/mm/mmu.c | 197 +++++++++++++++++++++++++++++++++++++++----- > 1 file changed, 176 insertions(+), 21 deletions(-) > > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index 5fb9a66f0754..7e95dbc69d57 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -29,6 +29,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -171,6 +172,87 @@ static void init_clear_pgtable(void *table) > dsb(ishst); > } > > +enum dm_type { > + PTE, > + CONT_PTE, > + PMD, > + CONT_PMD, > + PUD, > + NR_DM_TYPE, > +}; > + > +#ifdef CONFIG_PROC_FS > +static unsigned long dm_meminfo[NR_DM_TYPE]; > + > +void arch_report_meminfo(struct seq_file *m) > +{ > + const char *size[NR_DM_TYPE]; > + > +#if defined(CONFIG_ARM64_4K_PAGES) > + size[PTE] = "4k"; > + size[CONT_PTE] = "64k"; > + size[PMD] = "2M"; > + size[CONT_PMD] = "32M"; > + size[PUD] = "1G"; > +#elif defined(CONFIG_ARM64_16K_PAGES) > + size[PTE] = "16k"; > + size[CONT_PTE] = "2M"; > + size[PMD] = "32M"; > + size[CONT_PMD] = "1G"; > + size[PUD] = "64G"; > +#elif defined(CONFIG_ARM64_64K_PAGES) > + size[PTE] = "64k"; > + size[CONT_PTE] = "2M"; > + size[PMD] = "512M"; > + size[CONT_PMD] = "16G"; > + size[PUD] = "4T"; > +#endif > + > + seq_printf(m, "DirectMap%s: %8lu kB\n", > + size[PTE], dm_meminfo[PTE] >> 10); > + seq_printf(m, "DirectMap%s: %8lu kB\n", > + size[CONT_PTE], > + dm_meminfo[CONT_PTE] >> 10); > + seq_printf(m, "DirectMap%s: %8lu kB\n", > + size[PMD], dm_meminfo[PMD] >> 10); > + seq_printf(m, "DirectMap%s: %8lu kB\n", > + size[CONT_PMD], > + dm_meminfo[CONT_PMD] >> 10); > + if (pud_sect_supported()) > + seq_printf(m, "DirectMap%s: %8lu kB\n", > + size[PUD], dm_meminfo[PUD] >> 10); > +} > + > +static inline bool is_dm_addr(unsigned long addr) > +{ > + return (addr >= PAGE_OFFSET) && (addr < PAGE_END); > +} Just use __is_lm_address()? For better or worse, the arm64 arch code tends to talk about the "linear map" rather than the "direct map", so a little bit of renaming would be good (i.e. s/dm/lm/). I'm fine if you want to keep the user-visible strings as "DirectMap". Will