Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_glue.c
| Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | |||||
| #include <vm/vm_param.h> | #include <vm/vm_param.h> | ||||
| #include <vm/pmap.h> | #include <vm/pmap.h> | ||||
| #include <vm/vm_domainset.h> | #include <vm/vm_domainset.h> | ||||
| #include <vm/vm_map.h> | #include <vm/vm_map.h> | ||||
| #include <vm/vm_page.h> | #include <vm/vm_page.h> | ||||
| #include <vm/vm_pageout.h> | #include <vm/vm_pageout.h> | ||||
| #include <vm/vm_pagequeue.h> | #include <vm/vm_pagequeue.h> | ||||
| #include <vm/vm_object.h> | #include <vm/vm_object.h> | ||||
| #include <vm/vm_radix.h> | |||||
| #include <vm/vm_kern.h> | #include <vm/vm_kern.h> | ||||
| #include <vm/vm_extern.h> | #include <vm/vm_extern.h> | ||||
| #include <vm/vm_pager.h> | #include <vm/vm_pager.h> | ||||
| #include <vm/vm_phys.h> | #include <vm/vm_phys.h> | ||||
| #include <machine/cpu.h> | #include <machine/cpu.h> | ||||
| #if VM_NRESERVLEVEL > 1 | #if VM_NRESERVLEVEL > 1 | ||||
| ▲ Show 20 Lines • Show All 498 Lines • ▼ Show 20 Lines | |||||
| /* | /* | ||||
| * Allocate physical pages, following the specified NUMA policy, to back a | * Allocate physical pages, following the specified NUMA policy, to back a | ||||
| * kernel stack. | * kernel stack. | ||||
| */ | */ | ||||
| static int | static int | ||||
| vm_thread_stack_back(vm_offset_t ks, vm_page_t ma[], int npages, int req_class, | vm_thread_stack_back(vm_offset_t ks, vm_page_t ma[], int npages, int req_class, | ||||
| int domain) | int domain) | ||||
| { | { | ||||
| struct pctrie_iter pages; | |||||
| vm_object_t obj = vm_thread_kstack_size_to_obj(npages); | vm_object_t obj = vm_thread_kstack_size_to_obj(npages); | ||||
| vm_pindex_t pindex; | vm_pindex_t pindex; | ||||
| vm_page_t m; | vm_page_t m, mpred; | ||||
| int n; | int n; | ||||
| pindex = vm_kstack_pindex(ks, npages); | pindex = vm_kstack_pindex(ks, npages); | ||||
| VM_OBJECT_WLOCK(obj); | VM_OBJECT_WLOCK(obj); | ||||
| vm_page_iter_init(&pages, obj); | |||||
| mpred = vm_radix_iter_lookup_le(&pages, pindex); | |||||
| for (n = 0; n < npages;) { | for (n = 0; n < npages;) { | ||||
| m = vm_page_grab(obj, pindex + n, | m = vm_page_grab(obj, pindex + n, | ||||
| VM_ALLOC_NOCREAT | VM_ALLOC_WIRED); | VM_ALLOC_NOCREAT | VM_ALLOC_WIRED); | ||||
| if (m == NULL) { | if (m == NULL) { | ||||
| m = n > 0 ? ma[n - 1] : vm_page_mpred(obj, pindex); | m = vm_page_alloc_domain(&pages, obj, pindex + n, | ||||
| m = vm_page_alloc_domain_after(obj, pindex + n, domain, | domain, req_class | VM_ALLOC_WIRED, mpred); | ||||
| req_class | VM_ALLOC_WIRED, m); | |||||
| } | } | ||||
| if (m == NULL) | if (m == NULL) | ||||
| break; | break; | ||||
| ma[n++] = m; | ma[n++] = mpred = m; | ||||
| } | } | ||||
| if (n < npages) | if (n < npages) | ||||
| goto cleanup; | goto cleanup; | ||||
| VM_OBJECT_WUNLOCK(obj); | VM_OBJECT_WUNLOCK(obj); | ||||
| return (0); | return (0); | ||||
| cleanup: | cleanup: | ||||
| for (int i = 0; i < n; i++) { | for (int i = 0; i < n; i++) { | ||||
| ▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines | |||||