aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/procfs
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2009-06-23 20:45:22 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2009-06-23 20:45:22 +0000
commit3364c323e6ad143e0e95e2d1c7c3c3b880515860 (patch)
treeefadbd0bda4d9f0ec36869d4d465b2cabf2dcd1b /sys/fs/procfs
parent224fbf9fd641d4f4b44cc3d6a44c7eb1b272968a (diff)
downloadsrc-3364c323e6ad143e0e95e2d1c7c3c3b880515860.tar.gz
src-3364c323e6ad143e0e95e2d1c7c3c3b880515860.zip
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)
Notes
Notes: svn path=/head/; revision=194766
Diffstat (limited to 'sys/fs/procfs')
-rw-r--r--sys/fs/procfs/procfs_map.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/fs/procfs/procfs_map.c b/sys/fs/procfs/procfs_map.c
index ed04d38df771..dee99ad1f646 100644
--- a/sys/fs/procfs/procfs_map.c
+++ b/sys/fs/procfs/procfs_map.c
@@ -45,6 +45,7 @@
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/proc.h>
+#include <sys/resourcevar.h>
#include <sys/sbuf.h>
#ifdef COMPAT_IA32
#include <sys/sysent.h>
@@ -82,6 +83,7 @@ procfs_doprocmap(PFS_FILL_ARGS)
vm_map_entry_t entry, tmp_entry;
struct vnode *vp;
char *fullpath, *freepath;
+ struct uidinfo *uip;
int error, vfslocked;
unsigned int last_timestamp;
#ifdef COMPAT_IA32
@@ -134,6 +136,7 @@ procfs_doprocmap(PFS_FILL_ARGS)
if (obj->shadow_count == 1)
privateresident = obj->resident_page_count;
}
+ uip = (entry->uip) ? entry->uip : (obj ? obj->uip : NULL);
resident = 0;
addr = entry->start;
@@ -198,10 +201,11 @@ procfs_doprocmap(PFS_FILL_ARGS)
/*
* format:
- * start, end, resident, private resident, cow, access, type.
+ * start, end, resident, private resident, cow, access, type,
+ * charged, charged uid.
*/
error = sbuf_printf(sb,
- "0x%lx 0x%lx %d %d %p %s%s%s %d %d 0x%x %s %s %s %s\n",
+ "0x%lx 0x%lx %d %d %p %s%s%s %d %d 0x%x %s %s %s %s %s %d\n",
(u_long)e_start, (u_long)e_end,
resident, privateresident,
#ifdef COMPAT_IA32
@@ -215,7 +219,8 @@ procfs_doprocmap(PFS_FILL_ARGS)
ref_count, shadow_count, flags,
(e_eflags & MAP_ENTRY_COW)?"COW":"NCOW",
(e_eflags & MAP_ENTRY_NEEDS_COPY)?"NC":"NNC",
- type, fullpath);
+ type, fullpath,
+ uip ? "CH":"NCH", uip ? uip->ui_uid : -1);
if (freepath != NULL)
free(freepath, M_TEMP);