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/vm_unix.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/vm_unix.c')
-rw-r--r-- | sys/vm/vm_unix.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sys/vm/vm_unix.c b/sys/vm/vm_unix.c index 6bb9917..c07a1c1 100644 --- a/sys/vm/vm_unix.c +++ b/sys/vm/vm_unix.c @@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include <sys/lock.h> #include <sys/mutex.h> #include <sys/proc.h> +#include <sys/racct.h> #include <sys/resourcevar.h> #include <sys/sysproto.h> #include <sys/systm.h> @@ -116,9 +117,29 @@ obreak(td, uap) error = ENOMEM; goto done; } + PROC_LOCK(td->td_proc); + error = racct_set(td->td_proc, RACCT_DATA, new - base); + if (error != 0) { + PROC_UNLOCK(td->td_proc); + error = ENOMEM; + goto done; + } + error = racct_set(td->td_proc, RACCT_VMEM, + vm->vm_map.size + (new - old)); + if (error != 0) { + racct_set_force(td->td_proc, RACCT_DATA, old - base); + PROC_UNLOCK(td->td_proc); + error = ENOMEM; + goto done; + } + PROC_UNLOCK(td->td_proc); rv = vm_map_insert(&vm->vm_map, NULL, 0, old, new, VM_PROT_RW, VM_PROT_ALL, 0); if (rv != KERN_SUCCESS) { + PROC_LOCK(td->td_proc); + racct_set_force(td->td_proc, RACCT_DATA, old - base); + racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size); + PROC_UNLOCK(td->td_proc); error = ENOMEM; goto done; } @@ -144,6 +165,10 @@ obreak(td, uap) goto done; } vm->vm_dsize -= btoc(old - new); + PROC_LOCK(td->td_proc); + racct_set_force(td->td_proc, RACCT_DATA, new - base); + racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size); + PROC_UNLOCK(td->td_proc); } done: vm_map_unlock(&vm->vm_map); |