|
Link Here
|
| 155 |
|
156 |
|
| 156 |
static vm_ooffset_t swap_total; |
157 |
static vm_ooffset_t swap_total; |
| 157 |
SYSCTL_QUAD(_vm, OID_AUTO, swap_total, CTLFLAG_RD, &swap_total, 0, |
158 |
SYSCTL_QUAD(_vm, OID_AUTO, swap_total, CTLFLAG_RD, &swap_total, 0, |
| 158 |
"Total amount of available swap storage."); |
159 |
"Total bytes of all swap storages."); |
| 159 |
static vm_ooffset_t swap_reserved; |
160 |
static vm_ooffset_t swap_reserved; |
| 160 |
SYSCTL_QUAD(_vm, OID_AUTO, swap_reserved, CTLFLAG_RD, &swap_reserved, 0, |
161 |
SYSCTL_QUAD(_vm, OID_AUTO, swap_reserved, CTLFLAG_RD, &swap_reserved, 0, |
| 161 |
"Amount of swap storage needed to back all allocated anonymous memory."); |
162 |
"Amount of swap storage needed to back all allocated anonymous memory."); |
|
Link Here
|
| 315 |
#define SWM_FREE 0x02 /* free, period */ |
316 |
#define SWM_FREE 0x02 /* free, period */ |
| 316 |
#define SWM_POP 0x04 /* pop out */ |
317 |
#define SWM_POP 0x04 /* pop out */ |
| 317 |
|
318 |
|
| 318 |
int swap_pager_full = 2; /* swap space exhaustion (task killing) */ |
319 |
static int swap_pager_full = 2; /* swap space exhaustion (task killing) */ |
| 319 |
static int swap_pager_almost_full = 1; /* swap space exhaustion (w/hysteresis)*/ |
320 |
static int swap_pager_almost_full = 1; /* swap space exhaustion (w/hysteresis)*/ |
| 320 |
static int nsw_rcount; /* free read buffers */ |
321 |
static int nsw_rcount; /* free read buffers */ |
| 321 |
static int nsw_wcount_sync; /* limit write buffers / synchronous */ |
322 |
static int nsw_wcount_sync; /* limit write buffers / synchronous */ |
|
Link Here
|
| 550 |
*/ |
558 |
*/ |
| 551 |
n -= ((n + 2) / 3); |
559 |
n -= ((n + 2) / 3); |
| 552 |
} while (n > 0); |
560 |
} while (n > 0); |
|
|
561 |
n = uma_zone_get_max(swap_zone); |
| 553 |
if (n2 != n) |
562 |
if (n2 != n) |
| 554 |
printf("Swap zone entries reduced from %lu to %lu.\n", n2, n); |
563 |
printf("Swap zone entries reduced from %lu to %lu.\n", n2, n); |
| 555 |
swap_maxpages = n * SWAP_META_PAGES; |
564 |
swap_maxpages = n * SWAP_META_PAGES; |
|
Link Here
|
| 2108 |
|
2135 |
|
| 2109 |
/* |
2136 |
/* |
| 2110 |
* Check that the total amount of swap currently configured does not |
2137 |
* Check that the total amount of swap currently configured does not |
| 2111 |
* exceed half the theoretical maximum. If it does, print a warning |
2138 |
* exceed half or full of the maximum. If it does, print a warning |
| 2112 |
* message and return -1; otherwise, return 0. |
2139 |
* message accordingly. |
| 2113 |
*/ |
2140 |
*/ |
| 2114 |
static int |
2141 |
static void |
| 2115 |
swapon_check_swzone(unsigned long npages) |
2142 |
swapon_check_swzone() |
| 2116 |
{ |
2143 |
{ |
| 2117 |
unsigned long maxpages; |
2144 |
unsigned long npages = swap_total / PAGE_SIZE; |
| 2118 |
|
2145 |
|
| 2119 |
/* absolute maximum we can handle assuming 100% efficiency */ |
2146 |
printf("swap_pager_avail=%d and swap_maxpages=%lu\n", |
| 2120 |
maxpages = uma_zone_get_max(swap_zone) * SWAP_META_PAGES; |
2147 |
swap_pager_avail, swap_maxpages); |
| 2121 |
|
2148 |
|
|
|
2149 |
if (npages <= swap_maxpages / 2) { |
| 2150 |
return; |
| 2151 |
} |
| 2152 |
/* we exceeded maximum and won't be able to use extra pages */ |
| 2153 |
else if (npages > swap_maxpages) { |
| 2154 |
printf("warning: total configured swap (%lu pages) " |
| 2155 |
"exceeds maximum amount (%lu pages).\n", |
| 2156 |
npages, swap_maxpages); |
| 2157 |
printf("%d devices will be used in round-robin but " |
| 2158 |
"%lu pages will not be used\n", |
| 2159 |
nswapdev, npages - swap_maxpages); |
| 2160 |
return; |
| 2161 |
} |
| 2122 |
/* recommend using no more than half that amount */ |
2162 |
/* recommend using no more than half that amount */ |
| 2123 |
if (npages > maxpages / 2) { |
2163 |
else { |
| 2124 |
printf("warning: total configured swap (%lu pages) " |
2164 |
printf("warning: total configured swap (%lu pages) " |
| 2125 |
"exceeds maximum recommended amount (%lu pages).\n", |
2165 |
"exceeds maximum recommended amount (%lu pages).\n", |
| 2126 |
npages, maxpages / 2); |
2166 |
npages, swap_maxpages / 2); |
| 2127 |
printf("warning: increase kern.maxswzone " |
2167 |
printf("warning: increase kern.maxswzone " |
| 2128 |
"or reduce amount of swap.\n"); |
2168 |
"or reduce amount of swap.\n"); |
| 2129 |
return (-1); |
2169 |
return; |
| 2130 |
} |
2170 |
} |
| 2131 |
return (0); |
|
|
| 2132 |
} |
2171 |
} |
| 2133 |
|
2172 |
|
| 2134 |
static void |
2173 |
static void |
|
Link Here
|
| 2196 |
nswapdev++; |
2235 |
nswapdev++; |
| 2197 |
swap_pager_avail += nblks - 2; |
2236 |
swap_pager_avail += nblks - 2; |
| 2198 |
swap_total += (vm_ooffset_t)nblks * PAGE_SIZE; |
2237 |
swap_total += (vm_ooffset_t)nblks * PAGE_SIZE; |
| 2199 |
swapon_check_swzone(swap_total / PAGE_SIZE); |
2238 |
swapon_check_swzone(); |
| 2200 |
swp_sizecheck(); |
2239 |
swp_sizecheck(); |
| 2201 |
mtx_unlock(&sw_dev_mtx); |
2240 |
mtx_unlock(&sw_dev_mtx); |
| 2202 |
} |
2241 |
} |