aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/vm_phys.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2016-04-09 13:58:04 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2016-04-09 13:58:04 +0000
commit62d70a8174c9a78bf0caf7a405b5e7c670e28360 (patch)
treecd8ee1473372af94096c75121cdad26c77602e58 /sys/vm/vm_phys.c
parent0ff814e85443f21ca752d25a481139db3b300b0e (diff)
downloadsrc-62d70a8174c9a78bf0caf7a405b5e7c670e28360.tar.gz
src-62d70a8174c9a78bf0caf7a405b5e7c670e28360.zip
Add more fine-grained kernel options for NUMA support.
VM_NUMA_ALLOC is used to enable use of domain-aware memory allocation in the virtual memory system. DEVICE_NUMA is used to enable affinity reporting for devices such as bus_get_domain(). MAXMEMDOM must still be set to a value greater than for any NUMA support to be effective. Note that 'cpuset -gd' always works if MAXMEMDOM is enabled and the system supports NUMA. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D5782
Notes
Notes: svn path=/head/; revision=297748
Diffstat (limited to 'sys/vm/vm_phys.c')
-rw-r--r--sys/vm/vm_phys.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c
index 3979513bfd93..d2f1edbdb762 100644
--- a/sys/vm/vm_phys.c
+++ b/sys/vm/vm_phys.c
@@ -48,9 +48,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
-#if MAXMEMDOM > 1
#include <sys/proc.h>
-#endif
#include <sys/queue.h>
#include <sys/rwlock.h>
#include <sys/sbuf.h>
@@ -73,8 +71,10 @@ __FBSDID("$FreeBSD$");
_Static_assert(sizeof(long) * NBBY >= VM_PHYSSEG_MAX,
"Too many physsegs.");
+#ifdef VM_NUMA_ALLOC
struct mem_affinity *mem_affinity;
int *mem_locality;
+#endif
int vm_ndomains = 1;
@@ -144,7 +144,7 @@ static int sysctl_vm_phys_segs(SYSCTL_HANDLER_ARGS);
SYSCTL_OID(_vm, OID_AUTO, phys_segs, CTLTYPE_STRING | CTLFLAG_RD,
NULL, 0, sysctl_vm_phys_segs, "A", "Phys Seg Info");
-#if MAXMEMDOM > 1
+#ifdef VM_NUMA_ALLOC
static int sysctl_vm_phys_locality(SYSCTL_HANDLER_ARGS);
SYSCTL_OID(_vm, OID_AUTO, phys_locality, CTLTYPE_STRING | CTLFLAG_RD,
NULL, 0, sysctl_vm_phys_locality, "A", "Phys Locality Info");
@@ -159,7 +159,7 @@ SYSCTL_INT(_vm, OID_AUTO, ndomains, CTLFLAG_RD,
static struct mtx vm_default_policy_mtx;
MTX_SYSINIT(vm_default_policy, &vm_default_policy_mtx, "default policy mutex",
MTX_DEF);
-#if MAXMEMDOM > 1
+#ifdef VM_NUMA_ALLOC
static struct vm_domain_policy vm_default_policy =
VM_DOMAIN_POLICY_STATIC_INITIALISER(VM_POLICY_FIRST_TOUCH_ROUND_ROBIN, 0);
#else
@@ -277,7 +277,7 @@ vm_phys_fictitious_cmp(struct vm_phys_fictitious_seg *p1,
static __inline int
vm_rr_selectdomain(void)
{
-#if MAXMEMDOM > 1
+#ifdef VM_NUMA_ALLOC
struct thread *td;
td = curthread;
@@ -303,13 +303,13 @@ vm_rr_selectdomain(void)
static void
vm_policy_iterator_init(struct vm_domain_iterator *vi)
{
-#if MAXMEMDOM > 1
+#ifdef VM_NUMA_ALLOC
struct vm_domain_policy lcl;
#endif
vm_domain_iterator_init(vi);
-#if MAXMEMDOM > 1
+#ifdef VM_NUMA_ALLOC
/* Copy out the thread policy */
vm_domain_policy_localcopy(&lcl, &curthread->td_vm_dom_policy);
if (lcl.p.policy != VM_POLICY_NONE) {
@@ -433,7 +433,7 @@ int
vm_phys_mem_affinity(int f, int t)
{
-#if MAXMEMDOM > 1
+#ifdef VM_NUMA_ALLOC
if (mem_locality == NULL)
return (-1);
if (f >= vm_ndomains || t >= vm_ndomains)
@@ -444,7 +444,7 @@ vm_phys_mem_affinity(int f, int t)
#endif
}
-#if MAXMEMDOM > 1
+#ifdef VM_NUMA_ALLOC
/*
* Outputs the VM locality table.
*/
@@ -520,6 +520,7 @@ _vm_phys_create_seg(vm_paddr_t start, vm_paddr_t end, int domain)
static void
vm_phys_create_seg(vm_paddr_t start, vm_paddr_t end)
{
+#ifdef VM_NUMA_ALLOC
int i;
if (mem_affinity == NULL) {
@@ -544,6 +545,9 @@ vm_phys_create_seg(vm_paddr_t start, vm_paddr_t end)
mem_affinity[i].domain);
start = mem_affinity[i].end;
}
+#else
+ _vm_phys_create_seg(start, end, 0);
+#endif
}
/*