svn commit: r247661 - user/attilio/vmc-playground/sys/vm

Alan Cox alc at FreeBSD.org
Sat Mar 2 18:18:31 UTC 2013


Author: alc
Date: Sat Mar  2 18:18:30 2013
New Revision: 247661
URL: http://svnweb.freebsd.org/changeset/base/247661

Log:
  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

Modified:
  user/attilio/vmc-playground/sys/vm/vm_object.c

Modified: user/attilio/vmc-playground/sys/vm/vm_object.c
==============================================================================
--- user/attilio/vmc-playground/sys/vm/vm_object.c	Sat Mar  2 18:08:03 2013	(r247660)
+++ user/attilio/vmc-playground/sys/vm/vm_object.c	Sat Mar  2 18:18:30 2013	(r247661)
@@ -166,8 +166,9 @@ vm_object_zdtor(void *mem, int size, voi
 
 	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
 	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_p
 	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)


More information about the svn-src-user mailing list