git: 9fabf97682ce - main - arm64: fix free queue and reservation configuration for 16KB pages

From: Alan Cox <alc_at_FreeBSD.org>
Date: Sun, 24 Mar 2024 17:47:04 UTC
The branch main has been updated by alc:

URL: https://cgit.FreeBSD.org/src/commit/?id=9fabf97682ce494865c8b26c218f2d00a36c99ea

commit 9fabf97682ce494865c8b26c218f2d00a36c99ea
Author:     Eliot Solomon <ehs3@rice.edu>
AuthorDate: 2023-11-18 21:13:21 +0000
Commit:     Alan Cox <alc@FreeBSD.org>
CommitDate: 2024-03-24 17:22:20 +0000

    arm64: fix free queue and reservation configuration for 16KB pages
    
    Correctly configure the free page queues and the reservation size when
    the base page size is 16KB.  In particular, the reservation size was
    less than the L2 Block size, making L2 promotions and mappings all but
    impossible.
    
    Reviewed by:    markj
    Tested by:      gallatin
    Differential Revision:  https://reviews.freebsd.org/D42737
---
 sys/arm64/arm64/copyinout.S |  1 +
 sys/arm64/include/vmparam.h | 18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/sys/arm64/arm64/copyinout.S b/sys/arm64/arm64/copyinout.S
index 005fa61bfe82..23f56ae85daa 100644
--- a/sys/arm64/arm64/copyinout.S
+++ b/sys/arm64/arm64/copyinout.S
@@ -30,6 +30,7 @@
 #include <machine/asm.h>
 #include <sys/errno.h>
 
+#include <machine/param.h>
 #include <machine/vmparam.h>
 
 #include "assym.inc"
diff --git a/sys/arm64/include/vmparam.h b/sys/arm64/include/vmparam.h
index 0967d3c0aedf..d5d4a5691f37 100644
--- a/sys/arm64/include/vmparam.h
+++ b/sys/arm64/include/vmparam.h
@@ -99,8 +99,17 @@
  * are used by UMA, the physical memory allocator reduces the likelihood of
  * both 2MB page TLB misses and cache misses during the page table walk when
  * a 2MB page TLB miss does occur.
+ *
+ * When PAGE_SIZE is 16KB, an allocation size of 32MB is supported.  This
+ * size is used by level 0 reservations and L2 BLOCK mappings.
  */
+#if PAGE_SIZE == PAGE_SIZE_4K
 #define	VM_NFREEORDER		13
+#elif PAGE_SIZE == PAGE_SIZE_16K
+#define	VM_NFREEORDER		12
+#else
+#error Unsupported page size
+#endif
 
 /*
  * Enable superpage reservations: 1 level.
@@ -110,10 +119,17 @@
 #endif
 
 /*
- * Level 0 reservations consist of 512 pages.
+ * Level 0 reservations consist of 512 pages when PAGE_SIZE is 4KB, and
+ * 2048 pages when PAGE_SIZE is 16KB.
  */
 #ifndef	VM_LEVEL_0_ORDER
+#if PAGE_SIZE == PAGE_SIZE_4K
 #define	VM_LEVEL_0_ORDER	9
+#elif PAGE_SIZE == PAGE_SIZE_16K
+#define	VM_LEVEL_0_ORDER	11
+#else
+#error Unsupported page size
+#endif
 #endif
 
 /**