From e3674072596e4a11f628f4e23d1472741e99ca18 Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 29 Oct 2019 20:46:25 +0000 Subject: [PATCH] Drop the object lock earlier in fault and don't relock it after pmap_enter(). Recent changes in object and page locking have enabled more lock pushdown. Reviewed by: kib Tested by: pho Differential Revision: https://reviews.freebsd.org/D22036 --- sys/vm/vm_fault.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index b8d0924243cc..41facf49bbf4 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -184,11 +184,10 @@ unlock_vp(struct faultstate *fs) } 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); @@ -201,6 +200,14 @@ unlock_and_deallocate(struct faultstate *fs) unlock_vp(fs); } +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 @@ vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, 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 @@ vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, * 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(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, 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 @@ vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, /* * Unlock everything, and return */ - unlock_and_deallocate(&fs); + fault_deallocate(&fs); if (hardfault) { VM_CNT_INC(v_io_faults); curthread->td_ru.ru_majflt++;