From owner-svn-src-head@FreeBSD.ORG Sun Jun 2 16:18:04 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 273AF89C; Sun, 2 Jun 2013 16:18:04 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 19ED31F08; Sun, 2 Jun 2013 16:18:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r52GI33w042678; Sun, 2 Jun 2013 16:18:03 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r52GI33I042677; Sun, 2 Jun 2013 16:18:03 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <201306021618.r52GI33I042677@svn.freebsd.org> From: Alan Cox Date: Sun, 2 Jun 2013 16:18:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251257 - head/sys/kern X-SVN-Group: head 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.14 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: Sun, 02 Jun 2013 16:18:04 -0000 Author: alc Date: Sun Jun 2 16:18:03 2013 New Revision: 251257 URL: http://svnweb.freebsd.org/changeset/base/251257 Log: Reduce the scope of the VM object locking in brelse(). In my tests, this change reduced the total number of VM object lock acquisitions by brelse() by 74%. Sponsored by: EMC / Isilon Storage Division Modified: head/sys/kern/vfs_bio.c Modified: head/sys/kern/vfs_bio.c ============================================================================== --- head/sys/kern/vfs_bio.c Sun Jun 2 15:47:22 2013 (r251256) +++ head/sys/kern/vfs_bio.c Sun Jun 2 16:18:03 2013 (r251257) @@ -1522,7 +1522,6 @@ brelse(struct buf *bp) */ resid = bp->b_bufsize; foff = bp->b_offset; - VM_OBJECT_WLOCK(obj); for (i = 0; i < bp->b_npages; i++) { int had_bogus = 0; @@ -1536,6 +1535,7 @@ brelse(struct buf *bp) poff = OFF_TO_IDX(bp->b_offset); had_bogus = 1; + VM_OBJECT_RLOCK(obj); for (j = i; j < bp->b_npages; j++) { vm_page_t mtmp; mtmp = bp->b_pages[j]; @@ -1547,6 +1547,7 @@ brelse(struct buf *bp) bp->b_pages[j] = mtmp; } } + VM_OBJECT_RUNLOCK(obj); if ((bp->b_flags & (B_INVAL | B_UNMAPPED)) == 0) { BUF_CHECK_MAPPED(bp); @@ -1564,14 +1565,15 @@ brelse(struct buf *bp) (PAGE_SIZE - poffset) : resid; KASSERT(presid >= 0, ("brelse: extra page")); + VM_OBJECT_WLOCK(obj); vm_page_set_invalid(m, poffset, presid); + VM_OBJECT_WUNLOCK(obj); if (had_bogus) printf("avoided corruption bug in bogus_page/brelse code\n"); } resid -= PAGE_SIZE - (foff & PAGE_MASK); foff = (foff + PAGE_SIZE) & ~(off_t)PAGE_MASK; } - VM_OBJECT_WUNLOCK(obj); if (bp->b_flags & (B_INVAL | B_RELBUF)) vfs_vmio_release(bp);