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) _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"