diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2010-12-24 21:49:05 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2010-12-24 21:49:05 +0000 |
commit | 9862461215db05852e20ec99673eb0dc72645625 (patch) | |
tree | be64b09c10f73027dde512b3cdc99b36c2f18a8a /sys | |
parent | 6d5520db11fad94368362b4390a94b0d48675f66 (diff) |
add a param to uvm_map_hint to not skip over the heap, and use it as a last
resort if mmap fails otherwise to enable more complete address space
utilization. tested for a while with no ill effects.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/uvm/uvm_map.c | 8 | ||||
-rw-r--r-- | sys/uvm/uvm_map.h | 5 | ||||
-rw-r--r-- | sys/uvm/uvm_mmap.c | 9 |
3 files changed, 16 insertions, 6 deletions
diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 53aa5c4fe7c..91d5db39e64 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.c,v 1.130 2010/12/15 04:59:52 tedu Exp $ */ +/* $OpenBSD: uvm_map.c,v 1.131 2010/12/24 21:49:04 tedu Exp $ */ /* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */ /* @@ -1241,7 +1241,7 @@ uvm_map_pie(vaddr_t align) * creating a new mapping with "prot" protection. */ vaddr_t -uvm_map_hint(struct proc *p, vm_prot_t prot) +uvm_map_hint1(struct proc *p, vm_prot_t prot, int skipheap) { vaddr_t addr; @@ -1258,7 +1258,9 @@ uvm_map_hint(struct proc *p, vm_prot_t prot) } #endif /* start malloc/mmap after the brk */ - addr = (vaddr_t)p->p_vmspace->vm_daddr + BRKSIZ; + addr = (vaddr_t)p->p_vmspace->vm_daddr; + if (skipheap) + addr += BRKSIZ; #if !defined(__vax__) addr += arc4random() & (MIN((256 * 1024 * 1024), BRKSIZ) - 1); #endif diff --git a/sys/uvm/uvm_map.h b/sys/uvm/uvm_map.h index 0838713311b..0c05d491289 100644 --- a/sys/uvm/uvm_map.h +++ b/sys/uvm/uvm_map.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.h,v 1.43 2010/04/20 22:05:44 tedu Exp $ */ +/* $OpenBSD: uvm_map.h,v 1.44 2010/12/24 21:49:04 tedu Exp $ */ /* $NetBSD: uvm_map.h,v 1.24 2001/02/18 21:19:08 chs Exp $ */ /* @@ -287,7 +287,8 @@ int uvm_map_extract(vm_map_t, vaddr_t, vsize_t, vm_map_entry_t uvm_map_findspace(vm_map_t, vaddr_t, vsize_t, vaddr_t *, struct uvm_object *, voff_t, vsize_t, int); vaddr_t uvm_map_pie(vaddr_t); -vaddr_t uvm_map_hint(struct proc *, vm_prot_t); +#define uvm_map_hint(p, prot) uvm_map_hint1(p, prot, 1) +vaddr_t uvm_map_hint1(struct proc *, vm_prot_t, int); int uvm_map_inherit(vm_map_t, vaddr_t, vaddr_t, vm_inherit_t); int uvm_map_advice(vm_map_t, vaddr_t, vaddr_t, int); void uvm_map_init(void); diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c index 4e606dbf8ae..4ae8c3d3797 100644 --- a/sys/uvm/uvm_mmap.c +++ b/sys/uvm/uvm_mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_mmap.c,v 1.81 2010/12/15 04:59:53 tedu Exp $ */ +/* $OpenBSD: uvm_mmap.c,v 1.82 2010/12/24 21:49:04 tedu Exp $ */ /* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */ /* @@ -604,6 +604,13 @@ sys_mmap(struct proc *p, void *v, register_t *retval) error = uvm_mmap(&p->p_vmspace->vm_map, &addr, size, prot, maxprot, flags, handle, pos, p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur, p); + if (error == ENOMEM && !(flags & (MAP_FIXED | MAP_TRYFIXED))) { + /* once more, with feeling */ + addr = uvm_map_hint1(p, prot, 0); + error = uvm_mmap(&p->p_vmspace->vm_map, &addr, size, prot, + maxprot, flags, handle, pos, + p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur, p); + } if (error == 0) /* remember to add offset */ |