diff options
author | 2012-04-12 11:55:43 +0000 | |
---|---|---|
committer | 2012-04-12 11:55:43 +0000 | |
commit | 0372dd1a1eae4ba050be5b39b703fa30b6c232eb (patch) | |
tree | cb7f7c16f5dde85e18c2365c6aefd6fcd3f638a6 | |
parent | tedu(tm) pcc. (diff) | |
download | wireguard-openbsd-0372dd1a1eae4ba050be5b39b703fa30b6c232eb.tar.xz wireguard-openbsd-0372dd1a1eae4ba050be5b39b703fa30b6c232eb.zip |
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
-rw-r--r-- | sys/uvm/uvm_fault.c | 47 |
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 { |