From 89e63829ad34dcd56613a6662bc0d12d954c4ce4 Mon Sep 17 00:00:00 2001 From: alc Date: Wed, 15 Mar 2017 17:43:45 +0000 Subject: [PATCH] Relax the locking requirements for vm_object_page_noreuse(). While reviewing all uses of OFF_TO_IDX(), I observed that vm_object_page_noreuse() is requiring an exclusive lock on the object when, in fact, a shared lock suffices. Reviewed by: kib, markj MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D10011 --- sys/kern/vfs_default.c | 4 ++-- sys/vm/vm_object.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index d60f11c36061..cb8b5635dbd0 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1100,10 +1100,10 @@ vop_stdadvise(struct vop_advise_args *ap) if (vp->v_object != NULL) { start = trunc_page(ap->a_start); end = round_page(ap->a_end); - VM_OBJECT_WLOCK(vp->v_object); + VM_OBJECT_RLOCK(vp->v_object); vm_object_page_noreuse(vp->v_object, OFF_TO_IDX(start), OFF_TO_IDX(end)); - VM_OBJECT_WUNLOCK(vp->v_object); + VM_OBJECT_RUNLOCK(vp->v_object); } bo = &vp->v_bufobj; diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 49f6c5f77e27..d57984b38826 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1978,7 +1978,7 @@ vm_object_page_noreuse(vm_object_t object, vm_pindex_t start, vm_pindex_t end) struct mtx *mtx, *new_mtx; vm_page_t p, next; - VM_OBJECT_ASSERT_WLOCKED(object); + VM_OBJECT_ASSERT_LOCKED(object); KASSERT((object->flags & (OBJ_FICTITIOUS | OBJ_UNMANAGED)) == 0, ("vm_object_page_noreuse: illegal object %p", object)); if (object->resident_page_count == 0)