summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2002-12-20 05:10:32 +0000
committeralc <alc@FreeBSD.org>2002-12-20 05:10:32 +0000
commit380a78911f64a84d65a18601fe8b9fdb8b1fc577 (patch)
tree2b8b1bb0942d8efbdaf89a4ca36c1ee03b32f134 /sys
parentafe2ea2b71e11bcbd8ca620fbcb80f69fc277f66 (diff)
downloadFreeBSD-src-380a78911f64a84d65a18601fe8b9fdb8b1fc577.zip
FreeBSD-src-380a78911f64a84d65a18601fe8b9fdb8b1fc577.tar.gz
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.
Diffstat (limited to 'sys')
-rw-r--r--sys/vm/vm_object.c4
-rw-r--r--sys/vm/vm_object.h9
2 files changed, 11 insertions, 2 deletions
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index a6e0d51..7dca2ae 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -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);
/*
diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h
index 9f4e488..37a5472 100644
--- a/sys/vm/vm_object.h
+++ b/sys/vm/vm_object.h
@@ -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);
OpenPOWER on IntegriCloud