[PATCH v1 09/10] arm64: mm: Declare support for large anonymous folios

From: Ryan Roberts
Date: Mon Jun 26 2023 - 13:16:21 EST


For the unhinted case, when THP is not permitted for the vma, don't
allow anything bigger than 64K. This means we don't waste too much
memory. Additionally, for 4K pages this is the contpte size, and for
16K, this is (usually) the HPA size when the uarch feature is
implemented. For the hinted case, when THP is permitted for the vma,
allow the contpte size for all page size configurations; 64K for 4K, 2M
for 16K and 2M for 64K.

Signed-off-by: Ryan Roberts <ryan.roberts@xxxxxxx>
---
arch/arm64/Kconfig | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 343e1e1cae10..0e91b5bc8cd9 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -243,6 +243,7 @@ config ARM64
select TRACE_IRQFLAGS_SUPPORT
select TRACE_IRQFLAGS_NMI_SUPPORT
select HAVE_SOFTIRQ_ON_OWN_STACK
+ select ARCH_SUPPORTS_LARGE_ANON_FOLIO
help
ARM 64-bit (AArch64) Linux support.

@@ -281,6 +282,18 @@ config ARM64_CONT_PMD_SHIFT
default 5 if ARM64_16K_PAGES
default 4

+config ARCH_LARGE_ANON_FOLIO_NOTHP_ORDER_MAX
+ int
+ default 0 if ARM64_64K_PAGES # 64K (1 page)
+ default 2 if ARM64_16K_PAGES # 64K (4 pages; benefits from HPA where HW supports it)
+ default 4 if ARM64_4K_PAGES # 64K (16 pages; eligible for contpte-mapping)
+
+config ARCH_LARGE_ANON_FOLIO_THP_ORDER_MAX
+ int
+ default 5 if ARM64_64K_PAGES # 2M (32 page; eligible for contpte-mapping)
+ default 7 if ARM64_16K_PAGES # 2M (128 pages; eligible for contpte-mapping)
+ default 4 if ARM64_4K_PAGES # 64K (16 pages; eligible for contpte-mapping)
+
config ARCH_MMAP_RND_BITS_MIN
default 14 if ARM64_64K_PAGES
default 16 if ARM64_16K_PAGES
--
2.25.1