summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2013-03-02 18:18:30 +0000
committeralc <alc@FreeBSD.org>2013-03-02 18:18:30 +0000
commitc5b028cc14271bcdbc2499601cef11d2eb480c52 (patch)
tree2d3671db29fb4caa13ae9f4e58c595603605858f /sys/vm
parent89979cd21838696aea80a7b7d6b073f0a1b3d9a0 (diff)
downloadFreeBSD-src-c5b028cc14271bcdbc2499601cef11d2eb480c52.zip
FreeBSD-src-c5b028cc14271bcdbc2499601cef11d2eb480c52.tar.gz
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
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/vm_object.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 521044e..63e88a0 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -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)
OpenPOWER on IntegriCloud