Changeset View
Changeset View
Standalone View
Standalone View
vm/vm_page.c
Context not available. | |||||
vm_page_import(void *arg, void **store, int cnt, int domain, int flags) | vm_page_import(void *arg, void **store, int cnt, int domain, int flags) | ||||
{ | { | ||||
struct vm_domain *vmd; | struct vm_domain *vmd; | ||||
vm_page_t m; | int i; | ||||
int i, j, n; | |||||
vmd = arg; | vmd = arg; | ||||
/* Only import if we can bring in a full bucket. */ | /* Only import if we can bring in a full bucket. */ | ||||
Context not available. | |||||
if (cnt == 1 || !vm_domain_allocate(vmd, VM_ALLOC_NORMAL, cnt)) | if (cnt == 1 || !vm_domain_allocate(vmd, VM_ALLOC_NORMAL, cnt)) | ||||
return (0); | return (0); | ||||
domain = vmd->vmd_domain; | domain = vmd->vmd_domain; | ||||
n = 64; /* Starting stride, arbitrary. */ | |||||
vm_domain_free_lock(vmd); | vm_domain_free_lock(vmd); | ||||
for (i = 0; i < cnt; i+=n) { | i = vm_phys_alloc_npages(domain, VM_FREEPOOL_DEFAULT, cnt, | ||||
n = vm_phys_alloc_npages(domain, VM_FREELIST_DEFAULT, &m, | (vm_page_t *)store); | ||||
MIN(n, cnt-i)); | |||||
if (n == 0) | |||||
break; | |||||
for (j = 0; j < n; j++) | |||||
store[i+j] = m++; | |||||
} | |||||
vm_domain_free_unlock(vmd); | vm_domain_free_unlock(vmd); | ||||
if (cnt != i) | if (cnt != i) | ||||
vm_domain_freecnt_inc(vmd, cnt - i); | vm_domain_freecnt_inc(vmd, cnt - i); | ||||
Context not available. |