Author: kib Date: Wed Jun 1 20:39:00 2016 New Revision: 301165 URL: https://svnweb.freebsd.org/changeset/base/301165
Log: If the fast path unbusy in vm_page_replace() fails, slow path needs to acquire the page lock, which recurses. Avoid the recursion by reusing the code from vm_page_remove() in a new helper vm_page_xunbusy_maybelocked(). Reviewed by: alc Sponsored by: The FreeBSD Foundation Modified: head/sys/vm/vm_page.c Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Wed Jun 1 20:30:31 2016 (r301164) +++ head/sys/vm/vm_page.c Wed Jun 1 20:39:00 2016 (r301165) @@ -759,6 +759,22 @@ vm_page_trysbusy(vm_page_t m) } } +static void +vm_page_xunbusy_maybelocked(vm_page_t m) +{ + bool lockacq; + + vm_page_assert_xbusied(m); + + lockacq = !mtx_owned(vm_page_lockptr(m)); + if (lockacq) + vm_page_lock(m); + vm_page_flash(m); + atomic_store_rel_int(&m->busy_lock, VPB_UNBUSIED); + if (lockacq) + vm_page_unlock(m); +} + /* * vm_page_xunbusy_hard: * @@ -1197,25 +1213,14 @@ void vm_page_remove(vm_page_t m) { vm_object_t object; - boolean_t lockacq; if ((m->oflags & VPO_UNMANAGED) == 0) - vm_page_lock_assert(m, MA_OWNED); + vm_page_assert_locked(m); if ((object = m->object) == NULL) return; VM_OBJECT_ASSERT_WLOCKED(object); - if (vm_page_xbusied(m)) { - lockacq = FALSE; - if ((m->oflags & VPO_UNMANAGED) != 0 && - !mtx_owned(vm_page_lockptr(m))) { - lockacq = TRUE; - vm_page_lock(m); - } - vm_page_flash(m); - atomic_store_rel_int(&m->busy_lock, VPB_UNBUSIED); - if (lockacq) - vm_page_unlock(m); - } + if (vm_page_xbusied(m)) + vm_page_xunbusy_maybelocked(m); /* * Now remove from the object's list of backed pages. @@ -1340,7 +1345,7 @@ vm_page_replace(vm_page_t mnew, vm_objec TAILQ_REMOVE(&object->memq, mold, listq); mold->object = NULL; - vm_page_xunbusy(mold); + vm_page_xunbusy_maybelocked(mold); /* * The object's resident_page_count does not change because we have _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"