From b4762c84fbb2f99591248d99a3f0604dcf97ec8e Mon Sep 17 00:00:00 2001 From: alc Date: Thu, 20 Jun 2002 02:04:55 +0000 Subject: [PATCH] o Acquire and release the vm_map lock instead of Giant in obreak(). Consequently, use vm_map_insert() and vm_map_delete(), which expect the vm_map to be locked, instead of vm_map_find() and vm_map_remove(), which do not. --- sys/vm/vm_unix.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/sys/vm/vm_unix.c b/sys/vm/vm_unix.c index fc42092be938..6fcd2c5f3d31 100644 --- a/sys/vm/vm_unix.c +++ b/sys/vm/vm_unix.c @@ -78,10 +78,10 @@ obreak(td, uap) int rv; int error = 0; - mtx_lock(&Giant); /* syscall marked mp-safe but isn't */ + new = round_page((vm_offset_t)uap->nsize); + vm_map_lock(&vm->vm_map); base = round_page((vm_offset_t) vm->vm_daddr); - new = round_page((vm_offset_t)uap->nsize); old = base + ctob(vm->vm_dsize); if (new > base) { /* @@ -106,20 +106,16 @@ obreak(td, uap) error = EINVAL; goto done; } - if (new > old) { - vm_size_t diff; - - diff = new - old; - rv = vm_map_find(&vm->vm_map, NULL, 0, &old, diff, FALSE, - VM_PROT_ALL, VM_PROT_ALL, 0); + rv = vm_map_insert(&vm->vm_map, NULL, 0, old, new, + VM_PROT_ALL, VM_PROT_ALL, 0); if (rv != KERN_SUCCESS) { error = ENOMEM; goto done; } - vm->vm_dsize += btoc(diff); + vm->vm_dsize += btoc(new - old); } else if (new < old) { - rv = vm_map_remove(&vm->vm_map, new, old); + rv = vm_map_delete(&vm->vm_map, new, old); if (rv != KERN_SUCCESS) { error = ENOMEM; goto done; @@ -127,7 +123,7 @@ obreak(td, uap) vm->vm_dsize -= btoc(old - new); } done: - mtx_unlock(&Giant); + vm_map_unlock(&vm->vm_map); return (error); }