diff options
Diffstat (limited to 'sys/uvm/uvm_map.c')
-rw-r--r-- | sys/uvm/uvm_map.c | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index f30fae1c6da..4c02265a654 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.c,v 1.37 2002/01/23 00:39:48 art Exp $ */ +/* $OpenBSD: uvm_map.c,v 1.38 2002/02/18 10:02:20 art Exp $ */ /* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */ /* @@ -77,6 +77,7 @@ #include <sys/proc.h> #include <sys/malloc.h> #include <sys/pool.h> +#include <sys/kernel.h> #ifdef SYSVSHM #include <sys/shm.h> @@ -105,6 +106,7 @@ struct pool uvm_vmspace_pool; */ struct pool uvm_map_entry_pool; +struct pool uvm_map_entry_kmem_pool; #ifdef PMAP_GROWKERNEL /* @@ -189,39 +191,39 @@ static void uvm_map_unreference_amap __P((vm_map_entry_t, int)); /* * uvm_mapent_alloc: allocate a map entry - * - * => XXX: static pool for kernel map? */ static __inline vm_map_entry_t uvm_mapent_alloc(map) vm_map_t map; { - vm_map_entry_t me; + struct vm_map_entry *me; int s; - UVMHIST_FUNC("uvm_mapent_alloc"); - UVMHIST_CALLED(maphist); + UVMHIST_FUNC("uvm_mapent_alloc"); UVMHIST_CALLED(maphist); - if ((map->flags & VM_MAP_INTRSAFE) == 0 && - map != kernel_map && kernel_map != NULL /* XXX */) { - me = pool_get(&uvm_map_entry_pool, PR_WAITOK); - me->flags = 0; - /* me can't be null, wait ok */ - } else { - s = splvm(); /* protect kentry_free list with splvm */ + if (map->flags & VM_MAP_INTRSAFE || cold) { + s = splvm(); simple_lock(&uvm.kentry_lock); me = uvm.kentry_free; if (me) uvm.kentry_free = me->next; simple_unlock(&uvm.kentry_lock); splx(s); - if (!me) - panic("mapent_alloc: out of static map entries, check MAX_KMAPENT"); + if (me == NULL) { + panic("uvm_mapent_alloc: out of static map entries, " + "check MAX_KMAPENT (currently %d)", + MAX_KMAPENT); + } me->flags = UVM_MAP_STATIC; + } else if (map == kernel_map) { + me = pool_get(&uvm_map_entry_kmem_pool, PR_WAITOK); + me->flags = UVM_MAP_KMEM; + } else { + me = pool_get(&uvm_map_entry_pool, PR_WAITOK); + me->flags = 0; } - UVMHIST_LOG(maphist, "<- new entry=0x%x [kentry=%d]", - me, ((map->flags & VM_MAP_INTRSAFE) != 0 || map == kernel_map) - ? TRUE : FALSE, 0, 0); + UVMHIST_LOG(maphist, "<- new entry=0x%x [kentry=%d]", me, + ((map->flags & VM_MAP_INTRSAFE) != 0 || map == kernel_map), 0, 0); return(me); } @@ -236,19 +238,21 @@ uvm_mapent_free(me) vm_map_entry_t me; { int s; - UVMHIST_FUNC("uvm_mapent_free"); - UVMHIST_CALLED(maphist); - UVMHIST_LOG(maphist,"<- freeing map entry=0x%x [flags=%d]", + UVMHIST_FUNC("uvm_mapent_free"); UVMHIST_CALLED(maphist); + + UVMHIST_LOG(maphist,"<- freeing map entry=0x%x [flags=%d]", me, me->flags, 0, 0); - if ((me->flags & UVM_MAP_STATIC) == 0) { - pool_put(&uvm_map_entry_pool, me); - } else { - s = splvm(); /* protect kentry_free list with splvm */ + if (me->flags & UVM_MAP_STATIC) { + s = splvm(); simple_lock(&uvm.kentry_lock); me->next = uvm.kentry_free; uvm.kentry_free = me; simple_unlock(&uvm.kentry_lock); splx(s); + } else if (me->flags & UVM_MAP_KMEM) { + pool_put(&uvm_map_entry_kmem_pool, me); + } else { + pool_put(&uvm_map_entry_pool, me); } } @@ -358,6 +362,8 @@ uvm_map_init() 0, 0, 0, "vmsppl", &pool_allocator_nointr); pool_init(&uvm_map_entry_pool, sizeof(struct vm_map_entry), 0, 0, 0, "vmmpepl", &pool_allocator_nointr); + pool_init(&uvm_map_entry_kmem_pool, sizeof(struct vm_map_entry), + 0, 0, 0, "vmmpekpl", NULL); } /* |