Assert that the trie is empty when a vm object is destroyed.

Since vm objects are allocated from type-stable memory, we don't need to
initialize the trie's root in _vm_object_allocate() on every vm object
allocation.  We can instead do it once in vm_object_zinit().

We don't need to call vm_radix_reclaim_allnodes() in vm_object_terminate()
unless the resident page count is non-zero.

Reviewed by:	attilio
Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
alc 2013-03-02 18:18:30 +00:00
parent 89979cd218
commit c5b028cc14

View File

@ -166,8 +166,9 @@ vm_object_zdtor(void *mem, int size, void *arg)
object = (vm_object_t)mem;
KASSERT(TAILQ_EMPTY(&object->memq),
("object %p has resident pages",
object));
("object %p has resident pages in its memq", object));
KASSERT(object->rtree.rt_root == 0,
("object %p has resident pages in its trie", object));
#if VM_NRESERVLEVEL > 0
KASSERT(LIST_EMPTY(&object->rvq),
("object %p has reservations",
@ -198,6 +199,7 @@ vm_object_zinit(void *mem, int size, int flags)
mtx_init(&object->mtx, "vm object", NULL, MTX_DEF | MTX_DUPOK);
/* These are true for any object that has been freed */
object->rtree.rt_root = 0;
object->paging_in_progress = 0;
object->resident_page_count = 0;
object->shadow_count = 0;
@ -211,7 +213,6 @@ _vm_object_allocate(objtype_t type, vm_pindex_t size, vm_object_t object)
TAILQ_INIT(&object->memq);
LIST_INIT(&object->shadow_head);
object->rtree.rt_root = 0;
object->type = type;
switch (type) {
case OBJT_DEAD:
@ -736,13 +737,14 @@ vm_object_terminate(vm_object_t object)
}
vm_page_unlock(p);
}
vm_radix_reclaim_allnodes(&object->rtree);
/*
* If the object contained any pages, then reset it to an empty state.
* None of the object's fields, including "resident_page_count", were
* modified by the preceding loop.
*/
if (object->resident_page_count != 0) {
vm_radix_reclaim_allnodes(&object->rtree);
TAILQ_INIT(&object->memq);
object->resident_page_count = 0;
if (object->type == OBJT_VNODE)