diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2002-02-18 10:02:21 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2002-02-18 10:02:21 +0000 |
commit | 5b9faa3d36b8d9dd525bfecb28f05b7d60cf4869 (patch) | |
tree | 60d637be281e9df2d99fba6e3d13102379a9416d /sys | |
parent | 4841aa96aeb471dd7bfd90d63a87f74e9e42d52a (diff) |
From the UBC branch and NetBSD.
We allocate map entries for the non-intrsafe kernel map (most notably
kernel_map and exec_map) from a pool that's backed by kmem_map (to avoid
deadlocking).
This should get rid of MAX_KMAPENT panics.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/uvm/uvm_map.c | 56 | ||||
-rw-r--r-- | sys/uvm/uvm_map.h | 3 |
2 files changed, 33 insertions, 26 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); } /* diff --git a/sys/uvm/uvm_map.h b/sys/uvm/uvm_map.h index 724bd78ab23..ad865ece22b 100644 --- a/sys/uvm/uvm_map.h +++ b/sys/uvm/uvm_map.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.h,v 1.20 2001/12/19 08:58:07 art Exp $ */ +/* $OpenBSD: uvm_map.h,v 1.21 2002/02/18 10:02:20 art Exp $ */ /* $NetBSD: uvm_map.h,v 1.24 2001/02/18 21:19:08 chs Exp $ */ /* @@ -156,6 +156,7 @@ struct vm_map_entry { u_int8_t flags; /* flags */ #define UVM_MAP_STATIC 0x01 /* static map entry */ +#define UVM_MAP_KMEM 0x02 /* from kmem entry pool */ }; |