From owner-svn-src-head@freebsd.org Fri Nov 29 19:47:40 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AA6261BA519; Fri, 29 Nov 2019 19:47:40 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47PlR0440Zz4FhK; Fri, 29 Nov 2019 19:47:40 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6F02B1B072; Fri, 29 Nov 2019 19:47:40 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xATJleAs089578; Fri, 29 Nov 2019 19:47:40 GMT (envelope-from jeff@FreeBSD.org) Received: (from jeff@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xATJleHg089577; Fri, 29 Nov 2019 19:47:40 GMT (envelope-from jeff@FreeBSD.org) Message-Id: <201911291947.xATJleHg089577@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jeff set sender to jeff@FreeBSD.org using -f From: Jeff Roberson Date: Fri, 29 Nov 2019 19:47:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355215 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: jeff X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 355215 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Nov 2019 19:47:40 -0000 Author: jeff Date: Fri Nov 29 19:47:40 2019 New Revision: 355215 URL: https://svnweb.freebsd.org/changeset/base/355215 Log: Fix a perf regression from r355122. We can use a shared lock to drop the last ref on vnodes. Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D22565 Modified: head/sys/vm/vm_object.c Modified: head/sys/vm/vm_object.c ============================================================================== --- head/sys/vm/vm_object.c Fri Nov 29 18:05:54 2019 (r355214) +++ head/sys/vm/vm_object.c Fri Nov 29 19:47:40 2019 (r355215) @@ -520,15 +520,22 @@ static void vm_object_vndeallocate(vm_object_t object) { struct vnode *vp = (struct vnode *) object->handle; + bool last; KASSERT(object->type == OBJT_VNODE, ("vm_object_vndeallocate: not a vnode object")); KASSERT(vp != NULL, ("vm_object_vndeallocate: missing vp")); + /* Object lock to protect handle lookup. */ + last = refcount_release(&object->ref_count); + VM_OBJECT_RUNLOCK(object); + + if (!last) + return; + if (!umtx_shm_vnobj_persistent) umtx_shm_object_terminated(object); - VM_OBJECT_WUNLOCK(object); /* vrele may need the vnode lock. */ vrele(vp); } @@ -548,7 +555,7 @@ void vm_object_deallocate(vm_object_t object) { vm_object_t robject, temp; - bool last, released; + bool released; while (object != NULL) { /* @@ -565,18 +572,22 @@ vm_object_deallocate(vm_object_t object) if (released) return; - VM_OBJECT_WLOCK(object); - KASSERT(object->ref_count != 0, - ("vm_object_deallocate: object deallocated too many times: %d", object->type)); - - last = refcount_release(&object->ref_count); if (object->type == OBJT_VNODE) { - if (last) + VM_OBJECT_RLOCK(object); + if (object->type == OBJT_VNODE) { vm_object_vndeallocate(object); - else - VM_OBJECT_WUNLOCK(object); - return; + return; + } + VM_OBJECT_RUNLOCK(object); } + + VM_OBJECT_WLOCK(object); + KASSERT(object->ref_count > 0, + ("vm_object_deallocate: object deallocated too many times: %d", + object->type)); + + if (refcount_release(&object->ref_count)) + goto doterm; if (object->ref_count > 1) { VM_OBJECT_WUNLOCK(object); return;