From 3f25cbddc22e6f2e68a3fea0d09be17e97528487 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Wed, 21 Jul 2004 00:29:21 +0000 Subject: [PATCH] Move the initialization and teardown of pmaps to the vmspace zone's init and fini handlers. Our vm system removes all userland mappings at exit prior to calling pmap_release. It just so happens that we might as well reuse the pmap for the next process since the userland slate has already been wiped clean. However. There is a functional benefit to this as well. For platforms that share userland and kernel context in the same pmap, it means that the kernel portion of a pmap remains valid after the vmspace has been freed (process exit) and while it is in uma's cache. This is significant for i386 SMP systems with kernel context borrowing because it avoids a LOT of IPIs from the pmap_lazyfix() cleanup in the usual case. Tested on: amd64, i386, sparc64, alpha Glanced at by: alc --- sys/vm/vm_map.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index ba077963ef6..e5209b5cb6a 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -175,7 +175,7 @@ vmspace_zfini(void *mem, int size) struct vmspace *vm; vm = (struct vmspace *)mem; - + pmap_release(vmspace_pmap(vm)); vm_map_zfini(&vm->vm_map, sizeof(vm->vm_map)); } @@ -187,6 +187,7 @@ vmspace_zinit(void *mem, int size) vm = (struct vmspace *)mem; vm_map_zinit(&vm->vm_map, sizeof(vm->vm_map)); + pmap_pinit(vmspace_pmap(vm)); } static void @@ -254,7 +255,6 @@ vmspace_alloc(min, max) vm = uma_zalloc(vmspace_zone, M_WAITOK); CTR1(KTR_VM, "vmspace_alloc: %p", vm); _vm_map_init(&vm->vm_map, min, max); - pmap_pinit(vmspace_pmap(vm)); vm->vm_map.pmap = vmspace_pmap(vm); /* XXX */ vm->vm_refcnt = 1; vm->vm_shm = NULL; @@ -299,7 +299,6 @@ vmspace_dofree(struct vmspace *vm) vm->vm_map.max_offset); vm_map_unlock(&vm->vm_map); - pmap_release(vmspace_pmap(vm)); uma_zfree(vmspace_zone, vm); }