swap_pager.c (0d8243cc346523e4174c369e45a590d06868bad2) swap_pager.c (44f1c916109d4d88941d257b7c4c96c26ab55477)
1/*-
2 * Copyright (c) 1998 Matthew Dillon,
3 * Copyright (c) 1994 John S. Dyson
4 * Copyright (c) 1990 University of Utah.
5 * Copyright (c) 1982, 1986, 1989, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by

--- 189 unchanged lines hidden (view full) ---

198 if (error != 0)
199 return (0);
200#endif
201
202 res = 0;
203 mtx_lock(&sw_dev_mtx);
204 r = swap_reserved + incr;
205 if (overcommit & SWAP_RESERVE_ALLOW_NONWIRED) {
1/*-
2 * Copyright (c) 1998 Matthew Dillon,
3 * Copyright (c) 1994 John S. Dyson
4 * Copyright (c) 1990 University of Utah.
5 * Copyright (c) 1982, 1986, 1989, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by

--- 189 unchanged lines hidden (view full) ---

198 if (error != 0)
199 return (0);
200#endif
201
202 res = 0;
203 mtx_lock(&sw_dev_mtx);
204 r = swap_reserved + incr;
205 if (overcommit & SWAP_RESERVE_ALLOW_NONWIRED) {
206 s = cnt.v_page_count - cnt.v_free_reserved - cnt.v_wire_count;
206 s = vm_cnt.v_page_count - vm_cnt.v_free_reserved - vm_cnt.v_wire_count;
207 s *= PAGE_SIZE;
208 } else
209 s = 0;
210 s += swap_total;
211 if ((overcommit & SWAP_RESERVE_FORCE_ON) == 0 || r <= s ||
212 (error = priv_check(curthread, PRIV_VM_SWAP_NOQUOTA)) == 0) {
213 res = 1;
214 swap_reserved = r;

--- 325 unchanged lines hidden (view full) ---

540 mtx_unlock(&pbuf_mtx);
541
542 /*
543 * Initialize our zone. Right now I'm just guessing on the number
544 * we need based on the number of pages in the system. Each swblock
545 * can hold 16 pages, so this is probably overkill. This reservation
546 * is typically limited to around 32MB by default.
547 */
207 s *= PAGE_SIZE;
208 } else
209 s = 0;
210 s += swap_total;
211 if ((overcommit & SWAP_RESERVE_FORCE_ON) == 0 || r <= s ||
212 (error = priv_check(curthread, PRIV_VM_SWAP_NOQUOTA)) == 0) {
213 res = 1;
214 swap_reserved = r;

--- 325 unchanged lines hidden (view full) ---

540 mtx_unlock(&pbuf_mtx);
541
542 /*
543 * Initialize our zone. Right now I'm just guessing on the number
544 * we need based on the number of pages in the system. Each swblock
545 * can hold 16 pages, so this is probably overkill. This reservation
546 * is typically limited to around 32MB by default.
547 */
548 n = cnt.v_page_count / 2;
548 n = vm_cnt.v_page_count / 2;
549 if (maxswzone && n > maxswzone / sizeof(struct swblock))
550 n = maxswzone / sizeof(struct swblock);
551 n2 = n;
552 swap_zone = uma_zcreate("SWAPMETA", sizeof(struct swblock), NULL, NULL,
553 NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE | UMA_ZONE_VM);
554 if (swap_zone == NULL)
555 panic("failed to create swap_zone.");
556 do {

--- 1754 unchanged lines hidden (view full) ---

2311 nblks = sp->sw_nblks;
2312
2313 /*
2314 * We can turn off this swap device safely only if the
2315 * available virtual memory in the system will fit the amount
2316 * of data we will have to page back in, plus an epsilon so
2317 * the system doesn't become critically low on swap space.
2318 */
549 if (maxswzone && n > maxswzone / sizeof(struct swblock))
550 n = maxswzone / sizeof(struct swblock);
551 n2 = n;
552 swap_zone = uma_zcreate("SWAPMETA", sizeof(struct swblock), NULL, NULL,
553 NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE | UMA_ZONE_VM);
554 if (swap_zone == NULL)
555 panic("failed to create swap_zone.");
556 do {

--- 1754 unchanged lines hidden (view full) ---

2311 nblks = sp->sw_nblks;
2312
2313 /*
2314 * We can turn off this swap device safely only if the
2315 * available virtual memory in the system will fit the amount
2316 * of data we will have to page back in, plus an epsilon so
2317 * the system doesn't become critically low on swap space.
2318 */
2319 if (cnt.v_free_count + cnt.v_cache_count + swap_pager_avail <
2319 if (vm_cnt.v_free_count + vm_cnt.v_cache_count + swap_pager_avail <
2320 nblks + nswap_lowat) {
2321 return (ENOMEM);
2322 }
2323
2324 /*
2325 * Prevent further allocations on this device.
2326 */
2327 mtx_lock(&sw_dev_mtx);

--- 427 unchanged lines hidden ---
2320 nblks + nswap_lowat) {
2321 return (ENOMEM);
2322 }
2323
2324 /*
2325 * Prevent further allocations on this device.
2326 */
2327 mtx_lock(&sw_dev_mtx);

--- 427 unchanged lines hidden ---