diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2005-05-24 21:11:49 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2005-05-24 21:11:49 +0000 |
commit | 526f723825fc14fc3adc977232cec0676a08eb7c (patch) | |
tree | 0fb6ab3a0b0476e21c49f614105a0feb84507035 | |
parent | 9e6922c4f2ab274c1deb3ec49e66afaa5597782f (diff) |
add a new field to vm_space and use it to track the number of anon
pages a process uses. this is now the userland "data size" value.
ok art deraadt tdeval. thanks testers.
-rw-r--r-- | sys/arch/amd64/amd64/pmap.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/i386/pmap.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_extern.h | 10 | ||||
-rw-r--r-- | sys/uvm/uvm_io.c | 4 | ||||
-rw-r--r-- | sys/uvm/uvm_km.c | 4 | ||||
-rw-r--r-- | sys/uvm/uvm_map.c | 17 | ||||
-rw-r--r-- | sys/uvm/uvm_map.h | 7 | ||||
-rw-r--r-- | sys/uvm/uvm_map_i.h | 7 | ||||
-rw-r--r-- | sys/uvm/uvm_mmap.c | 11 | ||||
-rw-r--r-- | sys/uvm/uvm_pager.c | 4 |
11 files changed, 46 insertions, 32 deletions
diff --git a/sys/arch/amd64/amd64/pmap.c b/sys/arch/amd64/amd64/pmap.c index b58008e1d6f..3c046b12986 100644 --- a/sys/arch/amd64/amd64/pmap.c +++ b/sys/arch/amd64/amd64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.7 2004/07/22 15:50:18 art Exp $ */ +/* $OpenBSD: pmap.c,v 1.8 2005/05/24 21:11:47 tedu Exp $ */ /* $NetBSD: pmap.c,v 1.3 2003/05/08 18:13:13 thorpej Exp $ */ /* @@ -1586,7 +1586,7 @@ pmap_free_pvpage() /* unmap the page */ dead_entries = NULL; uvm_unmap_remove(map, (vaddr_t)pvp, ((vaddr_t)pvp) + PAGE_SIZE, - &dead_entries); + &dead_entries, NULL); vm_map_unlock(map); if (dead_entries != NULL) diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c index 76aff1121fc..7bbfe9db7d4 100644 --- a/sys/arch/i386/i386/pmap.c +++ b/sys/arch/i386/i386/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.80 2004/12/25 23:02:24 miod Exp $ */ +/* $OpenBSD: pmap.c,v 1.81 2005/05/24 21:11:46 tedu Exp $ */ /* $NetBSD: pmap.c,v 1.91 2000/06/02 17:46:37 thorpej Exp $ */ /* @@ -1630,7 +1630,7 @@ pmap_free_pvpage() /* unmap the page */ dead_entries = NULL; uvm_unmap_remove(map, (vaddr_t)pvp, ((vaddr_t)pvp) + PAGE_SIZE, - &dead_entries); + &dead_entries, NULL); vm_map_unlock(map); if (dead_entries != NULL) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 7dad32b0e3b..1c992643d97 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.124 2005/03/10 17:26:10 tedu Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.125 2005/05/24 21:11:48 tedu Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -1165,7 +1165,7 @@ fill_eproc(struct proc *p, struct eproc *ep) PHOLD(p); /* need for pstats */ ep->e_vm.vm_rssize = vm_resident_count(vm); ep->e_vm.vm_tsize = vm->vm_tsize; - ep->e_vm.vm_dsize = vm->vm_dsize; + ep->e_vm.vm_dsize = vm->vm_dused; ep->e_vm.vm_ssize = vm->vm_ssize; ep->e_pstats = *p->p_stats; ep->e_pstats_valid = 1; @@ -1297,7 +1297,7 @@ fill_kproc2(struct proc *p, struct kinfo_proc2 *ki) ki->p_vm_rssize = vm_resident_count(vm); ki->p_vm_tsize = vm->vm_tsize; - ki->p_vm_dsize = vm->vm_dsize; + ki->p_vm_dsize = vm->vm_dused; ki->p_vm_ssize = vm->vm_ssize; ki->p_forw = PTRTOINT64(p->p_forw); diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h index 4608f0360b0..fe93ea4ad4c 100644 --- a/sys/uvm/uvm_extern.h +++ b/sys/uvm/uvm_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_extern.h,v 1.55 2005/04/21 04:39:34 mickey Exp $ */ +/* $OpenBSD: uvm_extern.h,v 1.56 2005/05/24 21:11:47 tedu Exp $ */ /* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */ /* @@ -395,6 +395,7 @@ struct vmspace { segsz_t vm_swrss; /* resident set size before last swap */ segsz_t vm_tsize; /* text size (pages) XXX */ segsz_t vm_dsize; /* data size (pages) XXX */ + segsz_t vm_dused; /* data segment length (pages) XXX */ segsz_t vm_ssize; /* stack size (pages) */ caddr_t vm_taddr; /* user virtual address of text XXX */ caddr_t vm_daddr; /* user virtual address of data XXX */ @@ -517,9 +518,10 @@ void *uvm_km_getpage(boolean_t); void uvm_km_putpage(void *); /* uvm_map.c */ -int uvm_map(vm_map_t, vaddr_t *, vsize_t, +#define uvm_map(_m, _a, _sz, _u, _f, _al, _fl) uvm_map_p(_m, _a, _sz, _u, _f, _al, _fl, 0) +int uvm_map_p(vm_map_t, vaddr_t *, vsize_t, struct uvm_object *, voff_t, vsize_t, - uvm_flag_t); + uvm_flag_t, struct proc *); int uvm_map_pageable(vm_map_t, vaddr_t, vaddr_t, boolean_t, int); int uvm_map_pageable_all(vm_map_t, int, vsize_t); @@ -547,7 +549,7 @@ void uvm_total(struct vmtotal *); /* uvm_mmap.c */ int uvm_mmap(vm_map_t, vaddr_t *, vsize_t, vm_prot_t, vm_prot_t, int, - caddr_t, voff_t, vsize_t); + caddr_t, voff_t, vsize_t, struct proc *); /* uvm_page.c */ struct vm_page *uvm_pagealloc_strat(struct uvm_object *, diff --git a/sys/uvm/uvm_io.c b/sys/uvm/uvm_io.c index 4bbabf480a7..25702be8d4b 100644 --- a/sys/uvm/uvm_io.c +++ b/sys/uvm/uvm_io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_io.c,v 1.14 2002/10/29 18:30:21 art Exp $ */ +/* $OpenBSD: uvm_io.c,v 1.15 2005/05/24 21:11:47 tedu Exp $ */ /* $NetBSD: uvm_io.c,v 1.12 2000/06/27 17:29:23 mrg Exp $ */ /* @@ -139,7 +139,7 @@ uvm_io(map, uio) vm_map_lock(kernel_map); uvm_unmap_remove(kernel_map, kva, kva+chunksz, - &dead_entries); + &dead_entries, NULL); vm_map_unlock(kernel_map); if (dead_entries != NULL) diff --git a/sys/uvm/uvm_km.c b/sys/uvm/uvm_km.c index e34f1b4161c..0b1ca938c8c 100644 --- a/sys/uvm/uvm_km.c +++ b/sys/uvm/uvm_km.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_km.c,v 1.45 2004/12/30 08:28:39 niklas Exp $ */ +/* $OpenBSD: uvm_km.c,v 1.46 2005/05/24 21:11:47 tedu Exp $ */ /* $NetBSD: uvm_km.c,v 1.42 2001/01/14 02:10:01 thorpej Exp $ */ /* @@ -604,7 +604,7 @@ uvm_km_free_wakeup(map, addr, size) vm_map_lock(map); uvm_unmap_remove(map, trunc_page(addr), round_page(addr+size), - &dead_entries); + &dead_entries, NULL); wakeup(map); vm_map_unlock(map); diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 94e8b0918a2..9198785226c 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.c,v 1.70 2004/12/30 08:28:39 niklas Exp $ */ +/* $OpenBSD: uvm_map.c,v 1.71 2005/05/24 21:11:47 tedu Exp $ */ /* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */ /* @@ -695,7 +695,7 @@ uvm_map_clip_end(map, entry, end) */ int -uvm_map(map, startp, size, uobj, uoffset, align, flags) +uvm_map_p(map, startp, size, uobj, uoffset, align, flags, p) vm_map_t map; vaddr_t *startp; /* IN/OUT */ vsize_t size; @@ -703,6 +703,7 @@ uvm_map(map, startp, size, uobj, uoffset, align, flags) voff_t uoffset; vsize_t align; uvm_flag_t flags; + struct proc *p; { vm_map_entry_t prev_entry, new_entry; vm_prot_t prot = UVM_PROTECTION(flags), maxprot = @@ -849,6 +850,8 @@ uvm_map(map, startp, size, uobj, uoffset, align, flags) prev_entry->end += size; uvm_rb_fixup(map, prev_entry); map->size += size; + if (p && uobj == NULL) + p->p_vmspace->vm_dused += btoc(size); uvm_tree_sanity(map, "map leave 2"); @@ -914,6 +917,9 @@ step3: uvm_map_entry_link(map, prev_entry, new_entry); map->size += size; + if (p && uobj == NULL) + p->p_vmspace->vm_dused += btoc(size); + /* * Update the free space hint @@ -1363,10 +1369,11 @@ uvm_map_findspace(map, hint, length, result, uobj, uoffset, align, flags) */ void -uvm_unmap_remove(map, start, end, entry_list) +uvm_unmap_remove(map, start, end, entry_list, p) vm_map_t map; vaddr_t start,end; vm_map_entry_t *entry_list; /* OUT */ + struct proc *p; { vm_map_entry_t entry, first_entry, next; vaddr_t len; @@ -1430,6 +1437,8 @@ uvm_unmap_remove(map, start, end, entry_list) UVM_MAP_CLIP_END(map, entry, end); next = entry->next; len = entry->end - entry->start; + if (p && entry->object.uvm_obj == NULL) + p->p_vmspace->vm_dused -= btoc(len); /* * unwire before removing addresses from the pmap; otherwise @@ -3333,7 +3342,7 @@ uvmspace_free(vm) if (vm->vm_map.nentries) { uvm_unmap_remove(&vm->vm_map, vm->vm_map.min_offset, vm->vm_map.max_offset, - &dead_entries); + &dead_entries, NULL); if (dead_entries != NULL) uvm_unmap_detach(dead_entries, 0); } diff --git a/sys/uvm/uvm_map.h b/sys/uvm/uvm_map.h index bd10caedd98..6683fc90559 100644 --- a/sys/uvm/uvm_map.h +++ b/sys/uvm/uvm_map.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.h,v 1.31 2005/03/01 01:28:39 henning Exp $ */ +/* $OpenBSD: uvm_map.h,v 1.32 2005/05/24 21:11:47 tedu Exp $ */ /* $NetBSD: uvm_map.h,v 1.24 2001/02/18 21:19:08 chs Exp $ */ /* @@ -354,11 +354,12 @@ int uvm_map_reserve(vm_map_t, vsize_t, vaddr_t, vsize_t, vaddr_t *); void uvm_map_setup(vm_map_t, vaddr_t, vaddr_t, int); int uvm_map_submap(vm_map_t, vaddr_t, vaddr_t, vm_map_t); +#define uvm_unmap(_m, _s, _e) uvm_unmap_p(_m, _s, _e, 0) MAP_INLINE -void uvm_unmap(vm_map_t, vaddr_t, vaddr_t); +void uvm_unmap_p(vm_map_t, vaddr_t, vaddr_t, struct proc *); void uvm_unmap_detach(vm_map_entry_t,int); void uvm_unmap_remove(vm_map_t, vaddr_t, vaddr_t, - vm_map_entry_t *); + vm_map_entry_t *, struct proc *); #endif /* _KERNEL */ diff --git a/sys/uvm/uvm_map_i.h b/sys/uvm/uvm_map_i.h index c5d3a238c5b..8927c6dfb73 100644 --- a/sys/uvm/uvm_map_i.h +++ b/sys/uvm/uvm_map_i.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map_i.h,v 1.16 2002/10/29 18:30:21 art Exp $ */ +/* $OpenBSD: uvm_map_i.h,v 1.17 2005/05/24 21:11:47 tedu Exp $ */ /* $NetBSD: uvm_map_i.h,v 1.18 2000/11/27 08:40:04 chs Exp $ */ /* @@ -161,9 +161,10 @@ uvm_map_setup(map, min, max, flags) */ MAP_INLINE void -uvm_unmap(map, start, end) +uvm_unmap_p(map, start, end, p) vm_map_t map; vaddr_t start,end; + struct proc *p; { vm_map_entry_t dead_entries; UVMHIST_FUNC("uvm_unmap"); UVMHIST_CALLED(maphist); @@ -175,7 +176,7 @@ uvm_unmap(map, start, end) * detach from the dead entries... */ vm_map_lock(map); - uvm_unmap_remove(map, start, end, &dead_entries); + uvm_unmap_remove(map, start, end, &dead_entries, p); vm_map_unlock(map); if (dead_entries != NULL) diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c index 1e6fc9a5564..73f7ca37f31 100644 --- a/sys/uvm/uvm_mmap.c +++ b/sys/uvm/uvm_mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_mmap.c,v 1.55 2005/01/15 06:54:51 otto Exp $ */ +/* $OpenBSD: uvm_mmap.c,v 1.56 2005/05/24 21:11:47 tedu Exp $ */ /* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */ /* @@ -605,7 +605,7 @@ sys_mmap(p, v, retval) */ error = uvm_mmap(&p->p_vmspace->vm_map, &addr, size, prot, maxprot, - flags, handle, pos, p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur); + flags, handle, pos, p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur, p); if (error == 0) /* remember to add offset */ @@ -787,7 +787,7 @@ sys_munmap(p, v, retval) /* * doit! */ - uvm_unmap_remove(map, addr, addr + size, &dead_entries); + uvm_unmap_remove(map, addr, addr + size, &dead_entries, p); vm_map_unlock(map); /* and unlock */ @@ -1164,7 +1164,7 @@ sys_munlockall(p, v, retval) */ int -uvm_mmap(map, addr, size, prot, maxprot, flags, handle, foff, locklimit) +uvm_mmap(map, addr, size, prot, maxprot, flags, handle, foff, locklimit, p) vm_map_t map; vaddr_t *addr; vsize_t size; @@ -1173,6 +1173,7 @@ uvm_mmap(map, addr, size, prot, maxprot, flags, handle, foff, locklimit) caddr_t handle; /* XXX: VNODE? */ voff_t foff; vsize_t locklimit; + struct proc *p; { struct uvm_object *uobj; struct vnode *vp; @@ -1301,7 +1302,7 @@ uvm_mmap(map, addr, size, prot, maxprot, flags, handle, foff, locklimit) * do it! */ - retval = uvm_map(map, addr, size, uobj, foff, align, uvmflag); + retval = uvm_map_p(map, addr, size, uobj, foff, align, uvmflag, p); if (retval == KERN_SUCCESS) { /* diff --git a/sys/uvm/uvm_pager.c b/sys/uvm/uvm_pager.c index ae3babf1288..c415e211d64 100644 --- a/sys/uvm/uvm_pager.c +++ b/sys/uvm/uvm_pager.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pager.c,v 1.35 2004/02/23 06:19:32 drahn Exp $ */ +/* $OpenBSD: uvm_pager.c,v 1.36 2005/05/24 21:11:47 tedu Exp $ */ /* $NetBSD: uvm_pager.c,v 1.36 2000/11/27 18:26:41 chs Exp $ */ /* @@ -227,7 +227,7 @@ uvm_pagermapout(kva, npages) } vm_map_lock(pager_map); - uvm_unmap_remove(pager_map, kva, kva + size, &entries); + uvm_unmap_remove(pager_map, kva, kva + size, &entries, NULL); simple_lock(&pager_map_wanted_lock); if (pager_map_wanted) { pager_map_wanted = FALSE; |