- Convert vm_object_pip_wait() from using tsleep() to msleep().
- Make vm_object_pip_sleep() static. - Lock the vm_object when performing vm_object_pip_wait().
This commit is contained in:
parent
fa22802086
commit
1ca5895341
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=114074
@ -1169,7 +1169,9 @@ vinvalbuf(vp, flags, cred, td, slpflag, slptimeo)
|
||||
}
|
||||
VI_UNLOCK(vp);
|
||||
if (VOP_GETVOBJECT(vp, &object) == 0) {
|
||||
VM_OBJECT_LOCK(object);
|
||||
vm_object_pip_wait(object, "vnvlbx");
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
}
|
||||
VI_LOCK(vp);
|
||||
} while (vp->v_numoutput > 0);
|
||||
|
@ -428,7 +428,9 @@ swap_pager_dealloc(object)
|
||||
}
|
||||
mtx_unlock(&sw_alloc_mtx);
|
||||
|
||||
VM_OBJECT_LOCK(object);
|
||||
vm_object_pip_wait(object, "swpdea");
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
|
||||
/*
|
||||
* Free all remaining metadata. We only bother to free it from
|
||||
@ -1775,7 +1777,9 @@ swap_pager_swapoff(int devidx, int *sw_used)
|
||||
* We wait on an arbitrary object to clock our rescans
|
||||
* to the rate of paging completion.
|
||||
*/
|
||||
VM_OBJECT_LOCK(waitobj);
|
||||
vm_object_pip_wait(waitobj, "swpoff");
|
||||
VM_OBJECT_UNLOCK(waitobj);
|
||||
goto full_rescan;
|
||||
}
|
||||
if (*sw_used)
|
||||
|
@ -109,6 +109,7 @@ SYSCTL_INT(_vm, OID_AUTO, msync_flush_flags,
|
||||
|
||||
static void vm_object_qcollapse(vm_object_t object);
|
||||
static int vm_object_page_collect_flush(vm_object_t object, vm_page_t p, int curgeneration, int pagerflags);
|
||||
static void vm_object_pip_sleep(vm_object_t object, char *waitid);
|
||||
|
||||
/*
|
||||
* Virtual memory objects maintain the actual data
|
||||
@ -306,7 +307,7 @@ vm_object_pip_wakeupn(vm_object_t object, short i)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
vm_object_pip_sleep(vm_object_t object, char *waitid)
|
||||
{
|
||||
GIANT_REQUIRED;
|
||||
@ -323,9 +324,12 @@ vm_object_pip_sleep(vm_object_t object, char *waitid)
|
||||
void
|
||||
vm_object_pip_wait(vm_object_t object, char *waitid)
|
||||
{
|
||||
GIANT_REQUIRED;
|
||||
while (object->paging_in_progress)
|
||||
vm_object_pip_sleep(object, 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);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -537,12 +541,12 @@ vm_object_terminate(vm_object_t object)
|
||||
*/
|
||||
VM_OBJECT_LOCK(object);
|
||||
vm_object_set_flag(object, OBJ_DEAD);
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
|
||||
/*
|
||||
* wait for the pageout daemon to be done with the object
|
||||
*/
|
||||
vm_object_pip_wait(object, "objtrm");
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
|
||||
KASSERT(!object->paging_in_progress,
|
||||
("vm_object_terminate: pageout in progress"));
|
||||
|
@ -174,6 +174,7 @@ extern vm_object_t kmem_object;
|
||||
#define VM_OBJECT_LOCK_ASSERT(object, type) \
|
||||
mtx_assert(&(object)->mtx, (type))
|
||||
#define VM_OBJECT_LOCKED(object) mtx_owned(&(object)->mtx)
|
||||
#define VM_OBJECT_MTX(object) (&(object)->mtx)
|
||||
#define VM_OBJECT_UNLOCK(object) mtx_unlock(&(object)->mtx)
|
||||
|
||||
#define vm_object_lock(object) \
|
||||
@ -187,7 +188,6 @@ void vm_object_pip_add(vm_object_t object, short i);
|
||||
void vm_object_pip_subtract(vm_object_t object, short i);
|
||||
void vm_object_pip_wakeup(vm_object_t object);
|
||||
void vm_object_pip_wakeupn(vm_object_t object, short i);
|
||||
void vm_object_pip_sleep(vm_object_t object, char *waitid);
|
||||
void vm_object_pip_wait(vm_object_t object, char *waitid);
|
||||
|
||||
vm_object_t vm_object_allocate (objtype_t, vm_pindex_t);
|
||||
|
@ -139,9 +139,11 @@ vnode_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
|
||||
* If the object is being terminated, wait for it to
|
||||
* go away.
|
||||
*/
|
||||
while (((object = vp->v_object) != NULL) &&
|
||||
(object->flags & OBJ_DEAD)) {
|
||||
tsleep(object, PVM, "vadead", 0);
|
||||
while ((object = vp->v_object) != NULL) {
|
||||
VM_OBJECT_LOCK(object);
|
||||
if ((object->flags & OBJ_DEAD) == 0)
|
||||
break;
|
||||
msleep(object, VM_OBJECT_MTX(object), PDROP | PVM, "vadead", 0);
|
||||
}
|
||||
|
||||
if (vp->v_usecount == 0)
|
||||
@ -159,6 +161,7 @@ vnode_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
|
||||
vp->v_object = object;
|
||||
} else {
|
||||
object->ref_count++;
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
}
|
||||
VI_LOCK(vp);
|
||||
vp->v_usecount++;
|
||||
@ -182,7 +185,9 @@ vnode_pager_dealloc(object)
|
||||
if (vp == NULL)
|
||||
panic("vnode_pager_dealloc: pager already dealloced");
|
||||
|
||||
VM_OBJECT_LOCK(object);
|
||||
vm_object_pip_wait(object, "vnpdea");
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
|
||||
object->handle = NULL;
|
||||
object->type = OBJT_DEAD;
|
||||
|
Loading…
Reference in New Issue
Block a user