Lines 2168-2175
vm_page_alloc_contig(vm_object_t object, vm_pindex_t pindex, int req,
Link Here
|
2168 |
vm_paddr_t boundary, vm_memattr_t memattr) |
2168 |
vm_paddr_t boundary, vm_memattr_t memattr) |
2169 |
{ |
2169 |
{ |
2170 |
struct vm_domainset_iter di; |
2170 |
struct vm_domainset_iter di; |
|
|
2171 |
vm_page_t bounds[2]; |
2171 |
vm_page_t m; |
2172 |
vm_page_t m; |
2172 |
int domain; |
2173 |
int domain; |
|
|
2174 |
int start_segind; |
2175 |
|
2176 |
start_segind = vm_phys_lookup_segind(low); |
2173 |
|
2177 |
|
2174 |
vm_domainset_iter_page_init(&di, object, pindex, &domain, &req); |
2178 |
vm_domainset_iter_page_init(&di, object, pindex, &domain, &req); |
2175 |
do { |
2179 |
do { |
Lines 2177-2182
vm_page_alloc_contig(vm_object_t object, vm_pindex_t pindex, int req,
Link Here
|
2177 |
npages, low, high, alignment, boundary, memattr); |
2181 |
npages, low, high, alignment, boundary, memattr); |
2178 |
if (m != NULL) |
2182 |
if (m != NULL) |
2179 |
break; |
2183 |
break; |
|
|
2184 |
if (vm_phys_find_range(bounds, start_segind, domain, |
2185 |
npages, low, high) == -1) { |
2186 |
vm_domainset_iter_ignore(&di, domain); |
2187 |
} |
2180 |
} while (vm_domainset_iter_page(&di, object, &domain) == 0); |
2188 |
} while (vm_domainset_iter_page(&di, object, &domain) == 0); |
2181 |
|
2189 |
|
2182 |
return (m); |
2190 |
return (m); |
Lines 3020-3026
vm_page_reclaim_run(int req_class, int domain, u_long npages, vm_page_t m_run,
Link Here
|
3020 |
* "npages" must be greater than zero. Both "alignment" and "boundary" |
3028 |
* "npages" must be greater than zero. Both "alignment" and "boundary" |
3021 |
* must be a power of two. |
3029 |
* must be a power of two. |
3022 |
*/ |
3030 |
*/ |
3023 |
bool |
3031 |
int |
3024 |
vm_page_reclaim_contig_domain_ext(int domain, int req, u_long npages, |
3032 |
vm_page_reclaim_contig_domain_ext(int domain, int req, u_long npages, |
3025 |
vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary, |
3033 |
vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary, |
3026 |
int desired_runs) |
3034 |
int desired_runs) |
Lines 3028-3041
vm_page_reclaim_contig_domain_ext(int domain, int req, u_long npages,
Link Here
|
3028 |
struct vm_domain *vmd; |
3036 |
struct vm_domain *vmd; |
3029 |
vm_page_t bounds[2], m_run, _m_runs[NRUNS], *m_runs; |
3037 |
vm_page_t bounds[2], m_run, _m_runs[NRUNS], *m_runs; |
3030 |
u_long count, minalign, reclaimed; |
3038 |
u_long count, minalign, reclaimed; |
3031 |
int error, i, min_reclaim, nruns, options, req_class, segind; |
3039 |
int error, i, min_reclaim, nruns, options, req_class; |
3032 |
bool ret; |
3040 |
int segind, start_segind; |
|
|
3041 |
int ret; |
3033 |
|
3042 |
|
3034 |
KASSERT(npages > 0, ("npages is 0")); |
3043 |
KASSERT(npages > 0, ("npages is 0")); |
3035 |
KASSERT(powerof2(alignment), ("alignment is not a power of 2")); |
3044 |
KASSERT(powerof2(alignment), ("alignment is not a power of 2")); |
3036 |
KASSERT(powerof2(boundary), ("boundary is not a power of 2")); |
3045 |
KASSERT(powerof2(boundary), ("boundary is not a power of 2")); |
3037 |
|
3046 |
|
3038 |
ret = false; |
3047 |
ret = ENOMEM; |
3039 |
|
3048 |
|
3040 |
/* |
3049 |
/* |
3041 |
* If the caller wants to reclaim multiple runs, try to allocate |
3050 |
* If the caller wants to reclaim multiple runs, try to allocate |
Lines 3075-3080
vm_page_reclaim_contig_domain_ext(int domain, int req, u_long npages,
Link Here
|
3075 |
if (curproc == pageproc && req_class != VM_ALLOC_INTERRUPT) |
3084 |
if (curproc == pageproc && req_class != VM_ALLOC_INTERRUPT) |
3076 |
req_class = VM_ALLOC_SYSTEM; |
3085 |
req_class = VM_ALLOC_SYSTEM; |
3077 |
|
3086 |
|
|
|
3087 |
start_segind = vm_phys_lookup_segind(low); |
3088 |
if (vm_phys_find_range(bounds, start_segind, domain, npages, |
3089 |
low, high) == -1) { |
3090 |
ret = ERANGE; |
3091 |
goto done; |
3092 |
} |
3093 |
|
3078 |
/* |
3094 |
/* |
3079 |
* Return if the number of free pages cannot satisfy the requested |
3095 |
* Return if the number of free pages cannot satisfy the requested |
3080 |
* allocation. |
3096 |
* allocation. |
Lines 3096-3102
vm_page_reclaim_contig_domain_ext(int domain, int req, u_long npages,
Link Here
|
3096 |
* and restrictions, and record them in "m_runs". |
3112 |
* and restrictions, and record them in "m_runs". |
3097 |
*/ |
3113 |
*/ |
3098 |
count = 0; |
3114 |
count = 0; |
3099 |
segind = vm_phys_lookup_segind(low); |
3115 |
segind = start_segind; |
3100 |
while ((segind = vm_phys_find_range(bounds, segind, domain, |
3116 |
while ((segind = vm_phys_find_range(bounds, segind, domain, |
3101 |
npages, low, high)) != -1) { |
3117 |
npages, low, high)) != -1) { |
3102 |
while ((m_run = vm_page_scan_contig(npages, bounds[0], |
3118 |
while ((m_run = vm_page_scan_contig(npages, bounds[0], |
Lines 3124-3130
vm_page_reclaim_contig_domain_ext(int domain, int req, u_long npages,
Link Here
|
3124 |
if (error == 0) { |
3140 |
if (error == 0) { |
3125 |
reclaimed += npages; |
3141 |
reclaimed += npages; |
3126 |
if (reclaimed >= min_reclaim) { |
3142 |
if (reclaimed >= min_reclaim) { |
3127 |
ret = true; |
3143 |
ret = 0; |
3128 |
goto done; |
3144 |
goto done; |
3129 |
} |
3145 |
} |
3130 |
} |
3146 |
} |
Lines 3139-3145
vm_page_reclaim_contig_domain_ext(int domain, int req, u_long npages,
Link Here
|
3139 |
else if (options == VPSC_NOSUPER) |
3155 |
else if (options == VPSC_NOSUPER) |
3140 |
options = VPSC_ANY; |
3156 |
options = VPSC_ANY; |
3141 |
else if (options == VPSC_ANY) { |
3157 |
else if (options == VPSC_ANY) { |
3142 |
ret = reclaimed != 0; |
3158 |
if (reclaimed != 0) |
|
|
3159 |
ret = 0; |
3143 |
goto done; |
3160 |
goto done; |
3144 |
} |
3161 |
} |
3145 |
} |
3162 |
} |
Lines 3149-3155
vm_page_reclaim_contig_domain_ext(int domain, int req, u_long npages,
Link Here
|
3149 |
return (ret); |
3166 |
return (ret); |
3150 |
} |
3167 |
} |
3151 |
|
3168 |
|
3152 |
bool |
3169 |
int |
3153 |
vm_page_reclaim_contig_domain(int domain, int req, u_long npages, |
3170 |
vm_page_reclaim_contig_domain(int domain, int req, u_long npages, |
3154 |
vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary) |
3171 |
vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary) |
3155 |
{ |
3172 |
{ |
Lines 3157-3176
vm_page_reclaim_contig_domain(int domain, int req, u_long npages,
Link Here
|
3157 |
alignment, boundary, 1)); |
3174 |
alignment, boundary, 1)); |
3158 |
} |
3175 |
} |
3159 |
|
3176 |
|
3160 |
bool |
3177 |
int |
3161 |
vm_page_reclaim_contig(int req, u_long npages, vm_paddr_t low, vm_paddr_t high, |
3178 |
vm_page_reclaim_contig(int req, u_long npages, vm_paddr_t low, vm_paddr_t high, |
3162 |
u_long alignment, vm_paddr_t boundary) |
3179 |
u_long alignment, vm_paddr_t boundary) |
3163 |
{ |
3180 |
{ |
3164 |
struct vm_domainset_iter di; |
3181 |
struct vm_domainset_iter di; |
3165 |
int domain; |
3182 |
int domain, ret, status; |
3166 |
bool ret; |
3183 |
|
|
|
3184 |
ret = ERANGE; |
3167 |
|
3185 |
|
3168 |
vm_domainset_iter_page_init(&di, NULL, 0, &domain, &req); |
3186 |
vm_domainset_iter_page_init(&di, NULL, 0, &domain, &req); |
3169 |
do { |
3187 |
do { |
3170 |
ret = vm_page_reclaim_contig_domain(domain, req, npages, low, |
3188 |
status = vm_page_reclaim_contig_domain(domain, req, npages, low, |
3171 |
high, alignment, boundary); |
3189 |
high, alignment, boundary); |
3172 |
if (ret) |
3190 |
if (status == 0) |
3173 |
break; |
3191 |
return (0); |
|
|
3192 |
if (status != ENOMEM) |
3193 |
vm_domainset_iter_ignore(&di, domain); |
3194 |
else |
3195 |
ret = ENOMEM; |
3174 |
} while (vm_domainset_iter_page(&di, NULL, &domain) == 0); |
3196 |
} while (vm_domainset_iter_page(&di, NULL, &domain) == 0); |
3175 |
|
3197 |
|
3176 |
return (ret); |
3198 |
return (ret); |