- Define VM_OBJECT_LOCK_INIT().
- Avoid repeatedly mtx_init()ing and mtx_destroy()ing the vm_object's lock using UMA's uminit callback, in this case, vm_object_zinit().
This commit is contained in:
parent
beff3ce218
commit
72d436f39a
@ -181,6 +181,7 @@ vm_object_zinit(void *mem, int size)
|
||||
|
||||
object = (vm_object_t)mem;
|
||||
bzero(&object->mtx, sizeof(object->mtx));
|
||||
VM_OBJECT_LOCK_INIT(object);
|
||||
|
||||
/* These are true for any object that has been freed */
|
||||
object->paging_in_progress = 0;
|
||||
@ -193,8 +194,6 @@ _vm_object_allocate(objtype_t type, vm_pindex_t size, vm_object_t object)
|
||||
{
|
||||
int incr;
|
||||
|
||||
mtx_init(&object->mtx, "vm object", NULL, MTX_DEF | MTX_DUPOK);
|
||||
|
||||
TAILQ_INIT(&object->memq);
|
||||
TAILQ_INIT(&object->shadow_head);
|
||||
|
||||
@ -236,12 +235,15 @@ vm_object_init(void)
|
||||
mtx_init(&vm_object_list_mtx, "vm object_list", NULL, MTX_DEF);
|
||||
|
||||
kernel_object = &kernel_object_store;
|
||||
VM_OBJECT_LOCK_INIT(&kernel_object_store);
|
||||
_vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
|
||||
kernel_object);
|
||||
|
||||
kmem_object = &kmem_object_store;
|
||||
VM_OBJECT_LOCK_INIT(&kmem_object_store);
|
||||
_vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
|
||||
kmem_object);
|
||||
|
||||
obj_zone = uma_zcreate("VM OBJECT", sizeof (struct vm_object), NULL,
|
||||
#ifdef INVARIANTS
|
||||
vm_object_zdtor,
|
||||
@ -612,7 +614,6 @@ vm_object_terminate(vm_object_t object)
|
||||
TAILQ_REMOVE(&vm_object_list, object, object_list);
|
||||
mtx_unlock(&vm_object_list_mtx);
|
||||
|
||||
mtx_destroy(&object->mtx);
|
||||
wakeup(object);
|
||||
|
||||
/*
|
||||
@ -1611,8 +1612,6 @@ vm_object_collapse(vm_object_t object)
|
||||
);
|
||||
mtx_unlock(&vm_object_list_mtx);
|
||||
|
||||
mtx_destroy(&backing_object->mtx);
|
||||
|
||||
uma_zfree(obj_zone, backing_object);
|
||||
|
||||
object_collapses++;
|
||||
|
@ -173,6 +173,8 @@ extern vm_object_t kmem_object;
|
||||
#define VM_OBJECT_LOCK(object) mtx_lock(&(object)->mtx)
|
||||
#define VM_OBJECT_LOCK_ASSERT(object, type) \
|
||||
mtx_assert(&(object)->mtx, (type))
|
||||
#define VM_OBJECT_LOCK_INIT(object) mtx_init(&(object)->mtx, "vm object", \
|
||||
NULL, MTX_DEF | MTX_DUPOK)
|
||||
#define VM_OBJECT_LOCKED(object) mtx_owned(&(object)->mtx)
|
||||
#define VM_OBJECT_MTX(object) (&(object)->mtx)
|
||||
#define VM_OBJECT_UNLOCK(object) mtx_unlock(&(object)->mtx)
|
||||
|
Loading…
Reference in New Issue
Block a user