Index: head/sys/vm/vm_fault.c =================================================================== --- head/sys/vm/vm_fault.c +++ head/sys/vm/vm_fault.c @@ -184,11 +184,10 @@ } static void -unlock_and_deallocate(struct faultstate *fs) +fault_deallocate(struct faultstate *fs) { vm_object_pip_wakeup(fs->object); - VM_OBJECT_WUNLOCK(fs->object); if (fs->object != fs->first_object) { VM_OBJECT_WLOCK(fs->first_object); vm_page_free(fs->first_m); @@ -202,6 +201,14 @@ } static void +unlock_and_deallocate(struct faultstate *fs) +{ + + VM_OBJECT_WUNLOCK(fs->object); + fault_deallocate(fs); +} + +static void vm_fault_dirty(vm_map_entry_t entry, vm_page_t m, vm_prot_t prot, vm_prot_t fault_type, int fault_flags, bool set_wd) { @@ -1261,10 +1268,12 @@ fs.object, OFF_TO_IDX( fs.first_object->backing_object_offset)); #endif + VM_OBJECT_WUNLOCK(fs.object); fs.first_m = fs.m; fs.m = NULL; VM_CNT_INC(v_cow_optim); } else { + VM_OBJECT_WUNLOCK(fs.object); /* * Oh, well, lets copy it. */ @@ -1285,7 +1294,6 @@ * conditional */ vm_object_pip_wakeup(fs.object); - VM_OBJECT_WUNLOCK(fs.object); /* * We only try to prefault read-only mappings to the @@ -1405,7 +1413,6 @@ vm_fault_prefault(&fs, vaddr, faultcount > 0 ? behind : PFBAK, faultcount > 0 ? ahead : PFFOR, false); - VM_OBJECT_WLOCK(fs.object); /* * If the page is not wired down, then put it where the pageout daemon @@ -1427,7 +1434,7 @@ /* * Unlock everything, and return */ - unlock_and_deallocate(&fs); + fault_deallocate(&fs); if (hardfault) { VM_CNT_INC(v_io_faults); curthread->td_ru.ru_majflt++;