From owner-svn-src-all@FreeBSD.ORG Tue Feb 26 17:22:10 2013 Return-Path: Delivered-To: svn-src-all@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 1F18E761; Tue, 26 Feb 2013 17:22:10 +0000 (UTC) (envelope-from attilio@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 02C511144; Tue, 26 Feb 2013 17:22:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r1QHM9vI095027; Tue, 26 Feb 2013 17:22:09 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r1QHM9Sn095015; Tue, 26 Feb 2013 17:22:09 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201302261722.r1QHM9Sn095015@svn.freebsd.org> From: Attilio Rao Date: Tue, 26 Feb 2013 17:22:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r247323 - head/sys/vm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Feb 2013 17:22:10 -0000 Author: attilio Date: Tue Feb 26 17:22:08 2013 New Revision: 247323 URL: http://svnweb.freebsd.org/changeset/base/247323 Log: Wrap the sleeps synchronized by the vm_object lock into the specific macro VM_OBJECT_SLEEP(). This hides some implementation details like the usage of the msleep() primitive and the necessity to access to the lock address directly. For this reason VM_OBJECT_MTX() macro is now retired. Sponsored by: EMC / Isilon storage division Reviewed by: alc Tested by: pho Modified: head/sys/vm/swap_pager.c head/sys/vm/vm_object.c head/sys/vm/vm_object.h head/sys/vm/vm_page.c head/sys/vm/vnode_pager.c Modified: head/sys/vm/swap_pager.c ============================================================================== --- head/sys/vm/swap_pager.c Tue Feb 26 16:55:59 2013 (r247322) +++ head/sys/vm/swap_pager.c Tue Feb 26 17:22:08 2013 (r247323) @@ -1213,7 +1213,7 @@ swap_pager_getpages(vm_object_t object, while ((mreq->oflags & VPO_SWAPINPROG) != 0) { mreq->oflags |= VPO_WANTED; PCPU_INC(cnt.v_intrans); - if (msleep(mreq, VM_OBJECT_MTX(object), PSWP, "swread", hz*20)) { + if (VM_OBJECT_SLEEP(object, mreq, PSWP, "swread", hz * 20)) { printf( "swap_pager: indefinite wait buffer: bufobj: %p, blkno: %jd, size: %ld\n", bp->b_bufobj, (intmax_t)bp->b_blkno, bp->b_bcount); Modified: head/sys/vm/vm_object.c ============================================================================== --- head/sys/vm/vm_object.c Tue Feb 26 16:55:59 2013 (r247322) +++ head/sys/vm/vm_object.c Tue Feb 26 17:22:08 2013 (r247323) @@ -387,7 +387,7 @@ vm_object_pip_wait(vm_object_t object, c VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); while (object->paging_in_progress) { object->flags |= OBJ_PIPWNT; - msleep(object, VM_OBJECT_MTX(object), PVM, waitid, 0); + VM_OBJECT_SLEEP(object, object, PVM, waitid, 0); } } @@ -579,8 +579,7 @@ retry: } else if (object->paging_in_progress) { VM_OBJECT_UNLOCK(robject); object->flags |= OBJ_PIPWNT; - msleep(object, - VM_OBJECT_MTX(object), + VM_OBJECT_SLEEP(object, object, PDROP | PVM, "objde2", 0); VM_OBJECT_LOCK(robject); temp = robject->backing_object; @@ -1139,8 +1138,7 @@ shadowlookup: if (object != tobject) VM_OBJECT_UNLOCK(object); m->oflags |= VPO_WANTED; - msleep(m, VM_OBJECT_MTX(tobject), PDROP | PVM, "madvpo", - 0); + VM_OBJECT_SLEEP(tobject, m, PDROP | PVM, "madvpo" , 0); VM_OBJECT_LOCK(object); goto relookup; } @@ -1338,7 +1336,7 @@ retry: if ((m->oflags & VPO_BUSY) || m->busy) { VM_OBJECT_UNLOCK(new_object); m->oflags |= VPO_WANTED; - msleep(m, VM_OBJECT_MTX(orig_object), PVM, "spltwt", 0); + VM_OBJECT_SLEEP(orig_object, m, PVM, "spltwt" , 0); VM_OBJECT_LOCK(new_object); goto retry; } @@ -1496,7 +1494,7 @@ vm_object_backing_scan(vm_object_t objec if ((p->oflags & VPO_BUSY) || p->busy) { VM_OBJECT_UNLOCK(object); p->oflags |= VPO_WANTED; - msleep(p, VM_OBJECT_MTX(backing_object), + VM_OBJECT_SLEEP(backing_object, p, PDROP | PVM, "vmocol", 0); VM_OBJECT_LOCK(object); VM_OBJECT_LOCK(backing_object); Modified: head/sys/vm/vm_object.h ============================================================================== --- head/sys/vm/vm_object.h Tue Feb 26 16:55:59 2013 (r247322) +++ head/sys/vm/vm_object.h Tue Feb 26 17:22:08 2013 (r247323) @@ -210,7 +210,9 @@ extern struct vm_object kmem_object_stor mtx_init(&(object)->mtx, "vm object", \ (type), MTX_DEF | MTX_DUPOK) #define VM_OBJECT_LOCKED(object) mtx_owned(&(object)->mtx) -#define VM_OBJECT_MTX(object) (&(object)->mtx) +#define VM_OBJECT_SLEEP(object, wchan, pri, wmesg, timo) \ + msleep((wchan), &(object)->mtx, (pri), \ + (wmesg), (timo)) #define VM_OBJECT_TRYLOCK(object) mtx_trylock(&(object)->mtx) #define VM_OBJECT_UNLOCK(object) mtx_unlock(&(object)->mtx) Modified: head/sys/vm/vm_page.c ============================================================================== --- head/sys/vm/vm_page.c Tue Feb 26 16:55:59 2013 (r247322) +++ head/sys/vm/vm_page.c Tue Feb 26 17:22:08 2013 (r247323) @@ -763,7 +763,7 @@ vm_page_sleep(vm_page_t m, const char *m * it. */ m->oflags |= VPO_WANTED; - msleep(m, VM_OBJECT_MTX(m->object), PVM, msg, 0); + VM_OBJECT_SLEEP(m->object, m, PVM, msg, 0); } /* Modified: head/sys/vm/vnode_pager.c ============================================================================== --- head/sys/vm/vnode_pager.c Tue Feb 26 16:55:59 2013 (r247322) +++ head/sys/vm/vnode_pager.c Tue Feb 26 17:22:08 2013 (r247323) @@ -116,7 +116,7 @@ vnode_create_vobject(struct vnode *vp, o } VOP_UNLOCK(vp, 0); vm_object_set_flag(object, OBJ_DISCONNECTWNT); - msleep(object, VM_OBJECT_MTX(object), PDROP | PVM, "vodead", 0); + VM_OBJECT_SLEEP(object, object, PDROP | PVM, "vodead" , 0); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); } @@ -210,7 +210,7 @@ retry: if ((object->flags & OBJ_DEAD) == 0) break; vm_object_set_flag(object, OBJ_DISCONNECTWNT); - msleep(object, VM_OBJECT_MTX(object), PDROP | PVM, "vadead", 0); + VM_OBJECT_SLEEP(object, object, PDROP | PVM, "vadead" , 0); } if (vp->v_usecount == 0)