diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index da77d7faca3d..915029e23fe7 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1084,7 +1084,7 @@ vm_object_madvise(vm_object_t object, vm_pindex_t pindex, int count, int advise) if (vm_page_sleep_busy(m, TRUE, "madvpo")) goto relookup; - + vm_page_lock_queues(); if (advise == MADV_WILLNEED) { vm_page_activate(m); } else if (advise == MADV_DONTNEED) { @@ -1109,9 +1109,10 @@ vm_object_madvise(vm_object_t object, vm_pindex_t pindex, int count, int advise) m->dirty = 0; m->act_count = 0; vm_page_dontneed(m); - if (tobject->type == OBJT_SWAP) - swap_pager_freespace(tobject, tpindex, 1); } + vm_page_unlock_queues(); + if (advise == MADV_FREE && tobject->type == OBJT_SWAP) + swap_pager_freespace(tobject, tpindex, 1); } mtx_unlock(&Giant); } diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index cb613be239be..7ff34346035b 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -1466,7 +1466,7 @@ vm_page_dontneed(vm_page_t m) int dnw; int head; - GIANT_REQUIRED; + mtx_assert(&vm_page_queue_mtx, MA_OWNED); dnw = ++dnweight; /*