git: cb5bc8a748df - stable/14 - vm_page: Add corresponding sysctl knob for loader tunable

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Thu, 19 Oct 2023 14:02:49 UTC
The branch stable/14 has been updated by zlei:

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

commit cb5bc8a748dfefc68e3905e8fdf17e0484844383
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2023-10-12 10:14:49 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2023-10-19 14:00:57 +0000

    vm_page: Add corresponding sysctl knob for loader tunable
    
    The loader tunable 'vm.pgcache_zone_max_pcpu' does not have corresponding
    sysctl MIB entry. Add it so that it can be retrieved, and `sysctl -T`
    will also report it correctly.
    
    Reviewed by:    markj
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D42138
    
    (cherry picked from commit a55fbda874db31b804490567c69502c891b6ff61)
---
 sys/vm/vm_page.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index 4f3c4ba2d4d7..8496a39154de 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -198,6 +198,11 @@ vm_page_init(void *dummy)
 	bogus_page = vm_page_alloc_noobj(VM_ALLOC_WIRED);
 }
 
+static int pgcache_zone_max_pcpu;
+SYSCTL_INT(_vm, OID_AUTO, pgcache_zone_max_pcpu,
+    CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &pgcache_zone_max_pcpu, 0,
+    "Per-CPU page cache size");
+
 /*
  * The cache page zone is initialized later since we need to be able to allocate
  * pages before UMA is fully initialized.
@@ -209,9 +214,8 @@ vm_page_init_cache_zones(void *dummy __unused)
 	struct vm_pgcache *pgcache;
 	int cache, domain, maxcache, pool;
 
-	maxcache = 0;
-	TUNABLE_INT_FETCH("vm.pgcache_zone_max_pcpu", &maxcache);
-	maxcache *= mp_ncpus;
+	TUNABLE_INT_FETCH("vm.pgcache_zone_max_pcpu", &pgcache_zone_max_pcpu);
+	maxcache = pgcache_zone_max_pcpu * mp_ncpus;
 	for (domain = 0; domain < vm_ndomains; domain++) {
 		vmd = VM_DOMAIN(domain);
 		for (pool = 0; pool < VM_NFREEPOOL; pool++) {