diff options
author | trasz <trasz@FreeBSD.org> | 2011-04-05 20:23:59 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2011-04-05 20:23:59 +0000 |
commit | 92bec9b84c91c81031aecc423fd62e9a9b27b631 (patch) | |
tree | ff083b539865dc2215b27827e89a3109487e5979 /sys/vm/swap_pager.c | |
parent | fffd1b22a504ec96e5bf538ba769d4ea4f5c8ded (diff) | |
download | FreeBSD-src-92bec9b84c91c81031aecc423fd62e9a9b27b631.zip FreeBSD-src-92bec9b84c91c81031aecc423fd62e9a9b27b631.tar.gz |
Add accounting for most of the memory-related resources.
Sponsored by: The FreeBSD Foundation
Reviewed by: kib (earlier version)
Diffstat (limited to 'sys/vm/swap_pager.c')
-rw-r--r-- | sys/vm/swap_pager.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 39631a6..9a3af95 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -86,6 +86,7 @@ __FBSDID("$FreeBSD$"); #include <sys/namei.h> #include <sys/vnode.h> #include <sys/malloc.h> +#include <sys/racct.h> #include <sys/resource.h> #include <sys/resourcevar.h> #include <sys/sysctl.h> @@ -192,6 +193,12 @@ swap_reserve_by_cred(vm_ooffset_t incr, struct ucred *cred) if (incr & PAGE_MASK) panic("swap_reserve: & PAGE_MASK"); + PROC_LOCK(curproc); + error = racct_add(curproc, RACCT_SWAP, incr); + PROC_UNLOCK(curproc); + if (error != 0) + return (0); + res = 0; mtx_lock(&sw_dev_mtx); r = swap_reserved + incr; @@ -230,6 +237,12 @@ swap_reserve_by_cred(vm_ooffset_t incr, struct ucred *cred) curproc->p_pid, uip->ui_uid, incr); } + if (!res) { + PROC_LOCK(curproc); + racct_sub(curproc, RACCT_SWAP, incr); + PROC_UNLOCK(curproc); + } + return (res); } @@ -242,6 +255,10 @@ swap_reserve_force(vm_ooffset_t incr) swap_reserved += incr; mtx_unlock(&sw_dev_mtx); + PROC_LOCK(curproc); + racct_add_force(curproc, RACCT_SWAP, incr); + PROC_UNLOCK(curproc); + uip = curthread->td_ucred->cr_ruidinfo; PROC_LOCK(curproc); UIDINFO_VMSIZE_LOCK(uip); @@ -282,6 +299,8 @@ swap_release_by_cred(vm_ooffset_t decr, struct ucred *cred) printf("negative vmsize for uid = %d\n", uip->ui_uid); uip->ui_vmsize -= decr; UIDINFO_VMSIZE_UNLOCK(uip); + + racct_sub_cred(cred, RACCT_SWAP, decr); } static void swapdev_strategy(struct buf *, struct swdevt *sw); |