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/sys/resourcevar.h | |
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/sys/resourcevar.h')
-rw-r--r-- | sys/sys/resourcevar.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/sys/resourcevar.h b/sys/sys/resourcevar.h index 0a867d1..21728aa 100644 --- a/sys/sys/resourcevar.h +++ b/sys/sys/resourcevar.h @@ -86,9 +86,12 @@ struct plimit { * (a) Constant from inception * (b) Lockless, updated using atomics * (c) Locked by global uihashtbl_mtx + * (d) Locked by the ui_vmsize_mtx */ struct uidinfo { LIST_ENTRY(uidinfo) ui_hash; /* (c) hash chain of uidinfos */ + struct mtx ui_vmsize_mtx; + vm_ooffset_t ui_vmsize; /* (d) swap reservation by uid */ long ui_sbsize; /* (b) socket buffer space consumed */ long ui_proccnt; /* (b) number of processes */ long ui_ptscnt; /* (b) number of pseudo-terminals */ @@ -96,6 +99,9 @@ struct uidinfo { u_int ui_ref; /* (b) reference count */ }; +#define UIDINFO_VMSIZE_LOCK(ui) mtx_lock(&((ui)->ui_vmsize_mtx)) +#define UIDINFO_VMSIZE_UNLOCK(ui) mtx_unlock(&((ui)->ui_vmsize_mtx)) + struct proc; struct rusage_ext; struct thread; |