From 49f99b72515864c7f48e1d57295de7c122876049 Mon Sep 17 00:00:00 2001 From: attilio Date: Tue, 26 Feb 2013 17:22:08 +0000 Subject: 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 --- sys/vm/swap_pager.c | 2 +- sys/vm/vm_object.c | 12 +++++------- sys/vm/vm_object.h | 4 +++- sys/vm/vm_page.c | 2 +- sys/vm/vnode_pager.c | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'sys/vm') diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 44bff25..2659b67 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -1213,7 +1213,7 @@ swap_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage) 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); diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 32b0779..fbfd24e 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -387,7 +387,7 @@ vm_object_pip_wait(vm_object_t object, char *waitid) 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 object, int op) 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); diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 8134752..0cb63e9 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -210,7 +210,9 @@ extern struct vm_object kmem_object_store; 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) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index c952c05..44f7193 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -763,7 +763,7 @@ vm_page_sleep(vm_page_t m, const char *msg) * it. */ m->oflags |= VPO_WANTED; - msleep(m, VM_OBJECT_MTX(m->object), PVM, msg, 0); + VM_OBJECT_SLEEP(m->object, m, PVM, msg, 0); } /* diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index a6d78f4..40f9497 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -116,7 +116,7 @@ vnode_create_vobject(struct vnode *vp, off_t isize, struct thread *td) } 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) -- cgit v1.1