aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/vm_phys.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/vm/vm_phys.c')
-rw-r--r--sys/vm/vm_phys.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c
index 26cfd7a77ae2..3da8c05b481a 100644
--- a/sys/vm/vm_phys.c
+++ b/sys/vm/vm_phys.c
@@ -198,20 +198,32 @@ vm_phys_fictitious_cmp(struct vm_phys_fictitious_seg *p1,
(uintmax_t)p1->end, (uintmax_t)p2->start, (uintmax_t)p2->end);
}
-boolean_t
-vm_phys_domain_intersects(long mask, vm_paddr_t low, vm_paddr_t high)
+int
+vm_phys_domain_match(int prefer, vm_paddr_t low, vm_paddr_t high)
{
- struct vm_phys_seg *s;
- int idx;
-
- while ((idx = ffsl(mask)) != 0) {
- idx--; /* ffsl counts from 1 */
- mask &= ~(1UL << idx);
- s = &vm_phys_segs[idx];
- if (low < s->end && high > s->start)
- return (TRUE);
- }
- return (FALSE);
+#ifdef VM_NUMA_ALLOC
+ domainset_t mask;
+ int i;
+
+ if (vm_ndomains == 1 || mem_affinity == NULL)
+ return (0);
+
+ DOMAINSET_ZERO(&mask);
+ /*
+ * Check for any memory that overlaps low, high.
+ */
+ for (i = 0; mem_affinity[i].end != 0; i++)
+ if (mem_affinity[i].start <= high &&
+ mem_affinity[i].end >= low)
+ DOMAINSET_SET(mem_affinity[i].domain, &mask);
+ if (prefer != -1 && DOMAINSET_ISSET(prefer, &mask))
+ return (prefer);
+ if (DOMAINSET_EMPTY(&mask))
+ panic("vm_phys_domain_match: Impossible constraint");
+ return (DOMAINSET_FFS(&mask) - 1);
+#else
+ return (0);
+#endif
}
/*