Add a mutex to struct vm_object. Initialize and destroy that mutex
at appropriate times. For the moment, the mutex is only used on the kmem_object.
This commit is contained in:
parent
afe2ea2b71
commit
380a78911f
@ -192,6 +192,9 @@ _vm_object_allocate(objtype_t type, vm_pindex_t size, vm_object_t object)
|
||||
{
|
||||
int incr;
|
||||
|
||||
bzero(&object->mtx, sizeof(object->mtx));
|
||||
mtx_init(&object->mtx, "vm object", NULL, MTX_DEF);
|
||||
|
||||
TAILQ_INIT(&object->memq);
|
||||
TAILQ_INIT(&object->shadow_head);
|
||||
|
||||
@ -611,6 +614,7 @@ 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);
|
||||
|
||||
/*
|
||||
|
@ -72,6 +72,8 @@
|
||||
#define _VM_OBJECT_
|
||||
|
||||
#include <sys/queue.h>
|
||||
#include <sys/_lock.h>
|
||||
#include <sys/_mutex.h>
|
||||
|
||||
enum obj_type { OBJT_DEFAULT, OBJT_SWAP, OBJT_VNODE, OBJT_DEVICE, OBJT_PHYS,
|
||||
OBJT_DEAD };
|
||||
@ -88,6 +90,7 @@ typedef u_char objtype_t;
|
||||
*/
|
||||
|
||||
struct vm_object {
|
||||
struct mtx mtx;
|
||||
TAILQ_ENTRY(vm_object) object_list; /* list of all objects */
|
||||
TAILQ_HEAD(, vm_object) shadow_head; /* objects that this is a shadow for */
|
||||
TAILQ_ENTRY(vm_object) shadow_list; /* chain of shadow objects */
|
||||
@ -171,8 +174,10 @@ extern vm_object_t kmem_object;
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define vm_object_lock(object) mtx_lock(&Giant)
|
||||
#define vm_object_unlock(object) mtx_unlock(&Giant)
|
||||
#define vm_object_lock(object) \
|
||||
mtx_lock((object) == kmem_object ? &kmem_object->mtx : &Giant)
|
||||
#define vm_object_unlock(object) \
|
||||
mtx_unlock((object) == kmem_object ? &kmem_object->mtx : &Giant)
|
||||
|
||||
void vm_freeze_copyopts(vm_object_t, vm_pindex_t, vm_pindex_t);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user