git: b180f0040f95 - stable/13 - vm_phys: Add corresponding sysctl knob for loader tunable

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

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

commit b180f0040f95973a30fa26f5435e4bbab1197e80
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:17:30 +0000

    vm_phys: Add corresponding sysctl knob for loader tunable
    
    The loader tunable 'vm.numa.disabled' 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 c415cfc8be1b732a80f1ada6d52091e08eeb9ab5)
    (cherry picked from commit e26b7e8d02f648623ad343016533487634a16698)
---
 sys/vm/vm_phys.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c
index 0c51bfc3e5c2..6894040cbefd 100644
--- a/sys/vm/vm_phys.c
+++ b/sys/vm/vm_phys.c
@@ -74,6 +74,12 @@ _Static_assert(sizeof(long) * NBBY >= VM_PHYSSEG_MAX,
 #ifdef NUMA
 struct mem_affinity __read_mostly *mem_affinity;
 int __read_mostly *mem_locality;
+
+static int numa_disabled;
+static SYSCTL_NODE(_vm, OID_AUTO, numa, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
+    "NUMA options");
+SYSCTL_INT(_vm_numa, OID_AUTO, disabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH,
+    &numa_disabled, 0, "NUMA-awareness in the allocators is disabled");
 #endif
 
 int __read_mostly vm_ndomains = 1;
@@ -622,15 +628,14 @@ vm_phys_register_domains(int ndomains, struct mem_affinity *affinity,
     int *locality)
 {
 #ifdef NUMA
-	int d, i;
+	int i;
 
 	/*
 	 * For now the only override value that we support is 1, which
 	 * effectively disables NUMA-awareness in the allocators.
 	 */
-	d = 0;
-	TUNABLE_INT_FETCH("vm.numa.disabled", &d);
-	if (d)
+	TUNABLE_INT_FETCH("vm.numa.disabled", &numa_disabled);
+	if (numa_disabled)
 		ndomains = 1;
 
 	if (ndomains > 1) {