Author: jeff Date: Mon Aug 19 22:25:28 2019 New Revision: 351235 URL: https://svnweb.freebsd.org/changeset/base/351235
Log: Permit vm_pager_has_page() to run with a shared lock. Introduce VM_OBJECT_DROP/VM_OBJECT_PICKUP to handle functions that are called with uncertain lock state. Reviewed by: kib, markj Tested by: pho Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D21310 Modified: head/sys/vm/vm_object.h head/sys/vm/vm_pager.h head/sys/vm/vnode_pager.c Modified: head/sys/vm/vm_object.h ============================================================================== --- head/sys/vm/vm_object.h Mon Aug 19 21:59:02 2019 (r351234) +++ head/sys/vm/vm_object.h Mon Aug 19 22:25:28 2019 (r351235) @@ -255,6 +255,10 @@ extern struct vm_object kernel_object_store; rw_wowned(&(object)->lock) #define VM_OBJECT_WUNLOCK(object) \ rw_wunlock(&(object)->lock) +#define VM_OBJECT_DROP(object) \ + lock_class_rw.lc_unlock(&(object)->lock.lock_object) +#define VM_OBJECT_PICKUP(object, state) \ + lock_class_rw.lc_lock(&(object)->lock.lock_object, (state)) struct vnode; Modified: head/sys/vm/vm_pager.h ============================================================================== --- head/sys/vm/vm_pager.h Mon Aug 19 21:59:02 2019 (r351234) +++ head/sys/vm/vm_pager.h Mon Aug 19 22:25:28 2019 (r351235) @@ -151,7 +151,7 @@ vm_pager_has_page( ) { boolean_t ret; - VM_OBJECT_ASSERT_WLOCKED(object); + VM_OBJECT_ASSERT_LOCKED(object); ret = (*pagertab[object->type]->pgo_haspage) (object, offset, before, after); return (ret); Modified: head/sys/vm/vnode_pager.c ============================================================================== --- head/sys/vm/vnode_pager.c Mon Aug 19 21:59:02 2019 (r351234) +++ head/sys/vm/vnode_pager.c Mon Aug 19 22:25:28 2019 (r351235) @@ -355,13 +355,14 @@ vnode_pager_haspage(vm_object_t object, vm_pindex_t pi { struct vnode *vp = object->handle; daddr_t bn; + uintptr_t lockstate; int err; daddr_t reqblock; int poff; int bsize; int pagesperblock, blocksperpage; - VM_OBJECT_ASSERT_WLOCKED(object); + VM_OBJECT_ASSERT_LOCKED(object); /* * If no vp or vp is doomed or marked transparent to VM, we do not * have the page. @@ -384,9 +385,9 @@ vnode_pager_haspage(vm_object_t object, vm_pindex_t pi blocksperpage = (PAGE_SIZE / bsize); reqblock = pindex * blocksperpage; } - VM_OBJECT_WUNLOCK(object); + lockstate = VM_OBJECT_DROP(object); err = VOP_BMAP(vp, reqblock, NULL, &bn, after, before); - VM_OBJECT_WLOCK(object); + VM_OBJECT_PICKUP(object, lockstate); if (err) return TRUE; if (bn == -1) _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"