diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index e5673de0738f..e28c16c11592 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -306,7 +306,6 @@ RetryFault:; * which is not what we want. */ vm_page_lock(fs.m); - vm_page_lock_queues(); if ((fs.m->cow) && (fault_type & VM_PROT_WRITE) && (fs.object == fs.first_object)) { @@ -337,6 +336,7 @@ RetryFault:; * sleeping so that the page daemon is less * likely to reclaim it. */ + vm_page_lock_queues(); vm_page_flag_set(fs.m, PG_REFERENCED); vm_page_unlock_queues(); vm_page_unlock(fs.m); @@ -363,6 +363,7 @@ RetryFault:; vm_object_deallocate(fs.first_object); goto RetryFault; } + vm_page_lock_queues(); vm_pageq_remove(fs.m); vm_page_unlock_queues(); vm_page_unlock(fs.m); diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 5a8356e3054a..f8a3259bc852 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2233,6 +2233,7 @@ vm_page_cowfault(vm_page_t m) vm_object_t object; vm_pindex_t pindex; + mtx_assert(&vm_page_queue_mtx, MA_NOTOWNED); vm_page_lock_assert(m, MA_OWNED); object = m->object; VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); @@ -2243,7 +2244,6 @@ vm_page_cowfault(vm_page_t m) retry_alloc: pmap_remove_all(m); - vm_page_unlock_queues(); vm_page_remove(m); mnew = vm_page_alloc(object, pindex, VM_ALLOC_NORMAL | VM_ALLOC_NOBUSY); if (mnew == NULL) { @@ -2254,7 +2254,6 @@ vm_page_cowfault(vm_page_t m) VM_OBJECT_LOCK(object); if (m == vm_page_lookup(object, pindex)) { vm_page_lock(m); - vm_page_lock_queues(); goto retry_alloc; } else { /* @@ -2272,9 +2271,7 @@ vm_page_cowfault(vm_page_t m) */ vm_page_unlock(m); vm_page_lock(mnew); - vm_page_lock_queues(); vm_page_free(mnew); - vm_page_unlock_queues(); vm_page_unlock(mnew); vm_page_insert(m, object, pindex); } else { /* clear COW & copy page */