swap_pager.c (221096) | swap_pager.c (223825) |
---|---|
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 --- 53 unchanged lines hidden (view full) --- 62 * 63 * from: Utah $Hdr: swap_pager.c 1.4 91/04/30$ 64 * 65 * @(#)swap_pager.c 8.9 (Berkeley) 3/21/94 66 * @(#)vm_swap.c 8.5 (Berkeley) 2/17/94 67 */ 68 69#include <sys/cdefs.h> | 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 --- 53 unchanged lines hidden (view full) --- 62 * 63 * from: Utah $Hdr: swap_pager.c 1.4 91/04/30$ 64 * 65 * @(#)swap_pager.c 8.9 (Berkeley) 3/21/94 66 * @(#)vm_swap.c 8.5 (Berkeley) 2/17/94 67 */ 68 69#include <sys/cdefs.h> |
70__FBSDID("$FreeBSD: head/sys/vm/swap_pager.c 221096 2011-04-26 22:18:53Z obrien $"); | 70__FBSDID("$FreeBSD: head/sys/vm/swap_pager.c 223825 2011-07-06 20:06:44Z trasz $"); |
71 72#include "opt_swap.h" 73#include "opt_vm.h" 74 75#include <sys/param.h> 76#include <sys/systm.h> 77#include <sys/conf.h> 78#include <sys/kernel.h> --- 109 unchanged lines hidden (view full) --- 188 static struct timeval lastfail; 189 struct uidinfo *uip; 190 191 uip = cred->cr_ruidinfo; 192 193 if (incr & PAGE_MASK) 194 panic("swap_reserve: & PAGE_MASK"); 195 | 71 72#include "opt_swap.h" 73#include "opt_vm.h" 74 75#include <sys/param.h> 76#include <sys/systm.h> 77#include <sys/conf.h> 78#include <sys/kernel.h> --- 109 unchanged lines hidden (view full) --- 188 static struct timeval lastfail; 189 struct uidinfo *uip; 190 191 uip = cred->cr_ruidinfo; 192 193 if (incr & PAGE_MASK) 194 panic("swap_reserve: & PAGE_MASK"); 195 |
196#ifdef RACCT |
|
196 PROC_LOCK(curproc); 197 error = racct_add(curproc, RACCT_SWAP, incr); 198 PROC_UNLOCK(curproc); 199 if (error != 0) 200 return (0); | 197 PROC_LOCK(curproc); 198 error = racct_add(curproc, RACCT_SWAP, incr); 199 PROC_UNLOCK(curproc); 200 if (error != 0) 201 return (0); |
202#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; 207 s *= PAGE_SIZE; 208 } else --- 23 unchanged lines hidden (view full) --- 232 mtx_unlock(&sw_dev_mtx); 233 } 234 } 235 if (!res && ppsratecheck(&lastfail, &curfail, 1)) { 236 printf("uid %d, pid %d: swap reservation for %jd bytes failed\n", 237 curproc->p_pid, uip->ui_uid, incr); 238 } 239 | 203 204 res = 0; 205 mtx_lock(&sw_dev_mtx); 206 r = swap_reserved + incr; 207 if (overcommit & SWAP_RESERVE_ALLOW_NONWIRED) { 208 s = cnt.v_page_count - cnt.v_free_reserved - cnt.v_wire_count; 209 s *= PAGE_SIZE; 210 } else --- 23 unchanged lines hidden (view full) --- 234 mtx_unlock(&sw_dev_mtx); 235 } 236 } 237 if (!res && ppsratecheck(&lastfail, &curfail, 1)) { 238 printf("uid %d, pid %d: swap reservation for %jd bytes failed\n", 239 curproc->p_pid, uip->ui_uid, incr); 240 } 241 |
242#ifdef RACCT |
|
240 if (!res) { 241 PROC_LOCK(curproc); 242 racct_sub(curproc, RACCT_SWAP, incr); 243 PROC_UNLOCK(curproc); 244 } | 243 if (!res) { 244 PROC_LOCK(curproc); 245 racct_sub(curproc, RACCT_SWAP, incr); 246 PROC_UNLOCK(curproc); 247 } |
248#endif |
|
245 246 return (res); 247} 248 249void 250swap_reserve_force(vm_ooffset_t incr) 251{ 252 struct uidinfo *uip; 253 254 mtx_lock(&sw_dev_mtx); 255 swap_reserved += incr; 256 mtx_unlock(&sw_dev_mtx); 257 | 249 250 return (res); 251} 252 253void 254swap_reserve_force(vm_ooffset_t incr) 255{ 256 struct uidinfo *uip; 257 258 mtx_lock(&sw_dev_mtx); 259 swap_reserved += incr; 260 mtx_unlock(&sw_dev_mtx); 261 |
262#ifdef RACCT |
|
258 PROC_LOCK(curproc); 259 racct_add_force(curproc, RACCT_SWAP, incr); 260 PROC_UNLOCK(curproc); | 263 PROC_LOCK(curproc); 264 racct_add_force(curproc, RACCT_SWAP, incr); 265 PROC_UNLOCK(curproc); |
266#endif |
|
261 262 uip = curthread->td_ucred->cr_ruidinfo; 263 PROC_LOCK(curproc); 264 UIDINFO_VMSIZE_LOCK(uip); 265 uip->ui_vmsize += incr; 266 UIDINFO_VMSIZE_UNLOCK(uip); 267 PROC_UNLOCK(curproc); 268} --- 2413 unchanged lines hidden --- | 267 268 uip = curthread->td_ucred->cr_ruidinfo; 269 PROC_LOCK(curproc); 270 UIDINFO_VMSIZE_LOCK(uip); 271 uip->ui_vmsize += incr; 272 UIDINFO_VMSIZE_UNLOCK(uip); 273 PROC_UNLOCK(curproc); 274} --- 2413 unchanged lines hidden --- |