summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_object.c
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2013-02-26 20:18:25 +0000
committerattilio <attilio@FreeBSD.org>2013-02-26 20:18:25 +0000
commit43aa55b4cd434755d73076d4c3b9425eed5ac9d3 (patch)
treebaac5ce171e966b2b8a8f05225d879b0d7790ded /sys/vm/vm_object.c
parent210a93e7f7575c047adaa80ddfa1d465e9334d81 (diff)
downloadFreeBSD-src-43aa55b4cd434755d73076d4c3b9425eed5ac9d3.zip
FreeBSD-src-43aa55b4cd434755d73076d4c3b9425eed5ac9d3.tar.gz
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
Diffstat (limited to 'sys/vm/vm_object.c')
-rw-r--r--sys/vm/vm_object.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index 1d88fd9..f3e4b6c 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -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);
}
OpenPOWER on IntegriCloud