summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorAriane van der Steldt <ariane@cvs.openbsd.org>2012-04-12 11:55:44 +0000
committerAriane van der Steldt <ariane@cvs.openbsd.org>2012-04-12 11:55:44 +0000
commit74d28f6e8cd0424d6f5b27cd9e2b301796111043 (patch)
tree0e56d4b597cbe9f33d9fbaa00f73dc3fbaaef311 /sys
parent8291377c0c2b8e8bc596b120850953e2cf9d23fe (diff)
uvm: keep track of maxrss
The fault path is used to update the maxrss of the faulting proc. Doesn't affect anything, as it was 0 before. Requested by espie, "just commit it" deraadt
Diffstat (limited to 'sys')
-rw-r--r--sys/uvm/uvm_fault.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/sys/uvm/uvm_fault.c b/sys/uvm/uvm_fault.c
index ba8ea7c5cc7..ed0c2cf4202 100644
--- a/sys/uvm/uvm_fault.c
+++ b/sys/uvm/uvm_fault.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_fault.c,v 1.64 2012/03/23 15:51:26 guenther Exp $ */
+/* $OpenBSD: uvm_fault.c,v 1.65 2012/04/12 11:55:43 ariane Exp $ */
/* $NetBSD: uvm_fault.c,v 1.51 2000/08/06 00:22:53 thorpej Exp $ */
/*
@@ -178,6 +178,7 @@ static struct uvm_advice uvmadvice[] = {
static void uvmfault_amapcopy(struct uvm_faultinfo *);
static __inline void uvmfault_anonflush(struct vm_anon **, int);
void uvmfault_unlockmaps(struct uvm_faultinfo *, boolean_t);
+void uvmfault_update_stats(struct uvm_faultinfo *);
/*
* inline functions
@@ -521,6 +522,49 @@ uvmfault_anonget(struct uvm_faultinfo *ufi, struct vm_amap *amap,
}
/*
+ * Update statistics after fault resolution.
+ * - maxrss
+ */
+void
+uvmfault_update_stats(struct uvm_faultinfo *ufi)
+{
+ struct vm_map *map;
+ struct proc *p;
+ vsize_t res;
+#ifndef pmap_resident_count
+ struct vm_space *vm;
+#endif
+
+ map = ufi->orig_map;
+
+ /*
+ * Update the maxrss for the process.
+ */
+ if (map->flags & VM_MAP_ISVMSPACE) {
+ p = curproc;
+ KASSERT(p != NULL && &p->p_vmspace->vm_map == map);
+
+#ifdef pmap_resident_count
+ res = pmap_resident_count(map->pmap);
+#else
+ /*
+ * Rather inaccurate, but this is the current anon size
+ * of the vmspace. It's basically the resident size
+ * minus the mmapped in files/text.
+ */
+ vm = (struct vmspace*)map;
+ res = vm->dsize;
+#endif
+
+ /* Convert res from pages to kilobytes. */
+ res <<= (PAGE_SHIFT - 10);
+
+ if (p->p_ru.ru_maxrss < res)
+ p->p_ru.ru_maxrss = res;
+ }
+}
+
+/*
* F A U L T - m a i n e n t r y p o i n t
*/
@@ -1768,6 +1812,7 @@ uvmfault_unlockmaps(struct uvm_faultinfo *ufi, boolean_t write_locked)
return;
}
+ uvmfault_update_stats(ufi);
if (write_locked) {
vm_map_unlock(ufi->map);
} else {