Revert the moving of vm_object objects initialization:

the objects zone ensures type-stability and thus we want to execute
actual lock initialization only when the objects are brought into the
zone otherwise there could be races between lock threads doing
re-initilization and other threads that want to acquire the lock
without a reference.

Sponsored by:	EMC / Isilon storage division
Reported by:	alc
This commit is contained in:
attilio 2013-02-26 20:18:25 +00:00
parent 210a93e7f7
commit 43aa55b4cd

View File

@ -194,23 +194,20 @@ vm_object_zinit(void *mem, int size, int flags)
vm_object_t object;
object = (vm_object_t)mem;
bzero(&object->mtx, sizeof(object->mtx));
mtx_init(&object->mtx, "vm object", NULL, MTX_DEF | MTX_DUPOK);
/* These are true for any object that has been freed */
object->paging_in_progress = 0;
object->resident_page_count = 0;
object->shadow_count = 0;
/* It relies on vm object mutex to be initialized afterwards. */
return (0);
}
static void
_vm_object_allocate(objtype_t type, vm_pindex_t size, vm_object_t object,
const char *mtxname)
_vm_object_allocate(objtype_t type, vm_pindex_t size, vm_object_t object)
{
bzero(&object->mtx, sizeof(object->mtx));
mtx_init(&object->mtx, "vm object", mtxname, MTX_DEF | MTX_DUPOK);
TAILQ_INIT(&object->memq);
LIST_INIT(&object->shadow_head);
@ -270,15 +267,17 @@ vm_object_init(void)
TAILQ_INIT(&vm_object_list);
mtx_init(&vm_object_list_mtx, "vm object_list", NULL, MTX_DEF);
mtx_init(&kernel_object->mtx, "vm object", "kernel object", MTX_DEF);
_vm_object_allocate(OBJT_PHYS, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
kernel_object, "kernel object");
kernel_object);
#if VM_NRESERVLEVEL > 0
kernel_object->flags |= OBJ_COLORED;
kernel_object->pg_color = (u_short)atop(VM_MIN_KERNEL_ADDRESS);
#endif
mtx_init(&kmem_object->mtx, "vm object", "kmem object", MTX_DEF);
_vm_object_allocate(OBJT_PHYS, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
kmem_object, "kmem object");
kmem_object);
#if VM_NRESERVLEVEL > 0
kmem_object->flags |= OBJ_COLORED;
kmem_object->pg_color = (u_short)atop(VM_MIN_KERNEL_ADDRESS);
@ -404,7 +403,7 @@ vm_object_allocate(objtype_t type, vm_pindex_t size)
vm_object_t object;
object = (vm_object_t)uma_zalloc(obj_zone, M_WAITOK);
_vm_object_allocate(type, size, object, NULL);
_vm_object_allocate(type, size, object);
return (object);
}