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
This commit is contained in:
Attilio Rao 2013-02-26 17:22:08 +00:00
parent 8a4f65bc33
commit 0dde287b20
5 changed files with 12 additions and 12 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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)

View file

@ -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);
}
/*

View file

@ -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)