summaryrefslogtreecommitdiffstats
path: root/sys/vm/swap_pager.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2011-07-06 20:06:44 +0000
committertrasz <trasz@FreeBSD.org>2011-07-06 20:06:44 +0000
commit4a17b24427e55ec7e1862b08a0a9247f0717d010 (patch)
tree443d8da9aef22fdf042ab6f2cf16f5e2d4f04bd3 /sys/vm/swap_pager.c
parent1adac93bc0e2f40ac5d98734f9451cb1a0f42124 (diff)
downloadFreeBSD-src-4a17b24427e55ec7e1862b08a0a9247f0717d010.zip
FreeBSD-src-4a17b24427e55ec7e1862b08a0a9247f0717d010.tar.gz
All the racct_*() calls need to happen with the proc locked. Fixing this
won't happen before 9.0. This commit adds "#ifdef RACCT" around all the "PROC_LOCK(p); racct_whatever(p, ...); PROC_UNLOCK(p)" instances, in order to avoid useless locking/unlocking in kernels built without "options RACCT".
Diffstat (limited to 'sys/vm/swap_pager.c')
-rw-r--r--sys/vm/swap_pager.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 2868a2f..f421e4f 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -193,11 +193,13 @@ swap_reserve_by_cred(vm_ooffset_t incr, struct ucred *cred)
if (incr & PAGE_MASK)
panic("swap_reserve: & PAGE_MASK");
+#ifdef RACCT
PROC_LOCK(curproc);
error = racct_add(curproc, RACCT_SWAP, incr);
PROC_UNLOCK(curproc);
if (error != 0)
return (0);
+#endif
res = 0;
mtx_lock(&sw_dev_mtx);
@@ -237,11 +239,13 @@ swap_reserve_by_cred(vm_ooffset_t incr, struct ucred *cred)
curproc->p_pid, uip->ui_uid, incr);
}
+#ifdef RACCT
if (!res) {
PROC_LOCK(curproc);
racct_sub(curproc, RACCT_SWAP, incr);
PROC_UNLOCK(curproc);
}
+#endif
return (res);
}
@@ -255,9 +259,11 @@ swap_reserve_force(vm_ooffset_t incr)
swap_reserved += incr;
mtx_unlock(&sw_dev_mtx);
+#ifdef RACCT
PROC_LOCK(curproc);
racct_add_force(curproc, RACCT_SWAP, incr);
PROC_UNLOCK(curproc);
+#endif
uip = curthread->td_ucred->cr_ruidinfo;
PROC_LOCK(curproc);
OpenPOWER on IntegriCloud