diff options
author | kib <kib@FreeBSD.org> | 2009-06-23 20:45:22 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2009-06-23 20:45:22 +0000 |
commit | fa686c638eece83a18de058d1934f4722487818b (patch) | |
tree | efadbd0bda4d9f0ec36869d4d465b2cabf2dcd1b /sys/vm/vm_pager.c | |
parent | 39fa9f1c9918ad9bb25af4f1bbce28c34cb2cd65 (diff) | |
download | FreeBSD-src-fa686c638eece83a18de058d1934f4722487818b.zip FreeBSD-src-fa686c638eece83a18de058d1934f4722487818b.tar.gz |
Implement global and per-uid accounting of the anonymous memory. Add
rlimit RLIMIT_SWAP that limits the amount of swap that may be reserved
for the uid.
The accounting information (charge) is associated with either map entry,
or vm object backing the entry, assuming the object is the first one
in the shadow chain and entry does not require COW. Charge is moved
from entry to object on allocation of the object, e.g. during the mmap,
assuming the object is allocated, or on the first page fault on the
entry. It moves back to the entry on forks due to COW setup.
The per-entry granularity of accounting makes the charge process fair
for processes that change uid during lifetime, and decrements charge
for proper uid when region is unmapped.
The interface of vm_pager_allocate(9) is extended by adding struct ucred *,
that is used to charge appropriate uid when allocation if performed by
kernel, e.g. md(4).
Several syscalls, among them is fork(2), may now return ENOMEM when
global or per-uid limits are enforced.
In collaboration with: pho
Reviewed by: alc
Approved by: re (kensmith)
Diffstat (limited to 'sys/vm/vm_pager.c')
-rw-r--r-- | sys/vm/vm_pager.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index 6bb5b3b..3758d2b 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -88,7 +88,7 @@ int cluster_pbuf_freecnt = -1; /* unlimited to begin with */ static int dead_pager_getpages(vm_object_t, vm_page_t *, int, int); static vm_object_t dead_pager_alloc(void *, vm_ooffset_t, vm_prot_t, - vm_ooffset_t); + vm_ooffset_t, struct ucred *); static void dead_pager_putpages(vm_object_t, vm_page_t *, int, int, int *); static boolean_t dead_pager_haspage(vm_object_t, vm_pindex_t, int *, int *); static void dead_pager_dealloc(vm_object_t); @@ -105,7 +105,7 @@ dead_pager_getpages(obj, ma, count, req) static vm_object_t dead_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, - vm_ooffset_t off) + vm_ooffset_t off, struct ucred *cred) { return NULL; } @@ -227,14 +227,14 @@ vm_pager_bufferinit() */ vm_object_t vm_pager_allocate(objtype_t type, void *handle, vm_ooffset_t size, - vm_prot_t prot, vm_ooffset_t off) + vm_prot_t prot, vm_ooffset_t off, struct ucred *cred) { vm_object_t ret; struct pagerops *ops; ops = pagertab[type]; if (ops) - ret = (*ops->pgo_alloc) (handle, size, prot, off); + ret = (*ops->pgo_alloc) (handle, size, prot, off, cred); else ret = NULL; return (ret); |