diff options
author | attilio <attilio@FreeBSD.org> | 2013-02-20 10:38:34 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2013-02-20 10:38:34 +0000 |
commit | 658534ed5a02db4fef5b0630008502474d6c26d6 (patch) | |
tree | 567755b13eb4e24198cc8098e62ff4a975f8486c /sys/vm/vm_object.h | |
parent | 5dce0c1384f698b3a27a82e72e3cbcf49b325404 (diff) | |
download | FreeBSD-src-658534ed5a02db4fef5b0630008502474d6c26d6.zip FreeBSD-src-658534ed5a02db4fef5b0630008502474d6c26d6.tar.gz |
Switch vm_object lock to be a rwlock.
* VM_OBJECT_LOCK and VM_OBJECT_UNLOCK are mapped to write operations
* VM_OBJECT_SLEEP() is introduced as a general purpose primitve to
get a sleep operation using a VM_OBJECT_LOCK() as protection
* The approach must bear with vm_pager.h namespace pollution so many
files require including directly rwlock.h
Diffstat (limited to 'sys/vm/vm_object.h')
-rw-r--r-- | sys/vm/vm_object.h | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 8134752..c01c638 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -70,15 +70,16 @@ #include <sys/queue.h> #include <sys/_lock.h> #include <sys/_mutex.h> +#include <sys/_rwlock.h> /* * Types defined: * * vm_object_t Virtual memory object. * - * The root of cached pages pool is protected by both the per-object mutex + * The root of cached pages pool is protected by both the per-object lock * and the free pages queue mutex. - * On insert in the cache splay tree, the per-object mutex is expected + * On insert in the cache splay tree, the per-object lock is expected * to be already held and the free pages queue mutex will be * acquired during the operation too. * On remove and lookup from the cache splay tree, only the free @@ -89,13 +90,13 @@ * * List of locks * (c) const until freed - * (o) per-object mutex + * (o) per-object lock * (f) free pages queue mutex * */ struct vm_object { - struct mtx mtx; + struct rwlock lock; TAILQ_ENTRY(vm_object) object_list; /* list of all objects */ LIST_HEAD(, vm_object) shadow_head; /* objects that this is a shadow for */ LIST_ENTRY(vm_object) shadow_list; /* chain of shadow objects */ @@ -203,16 +204,22 @@ extern struct vm_object kmem_object_store; #define kernel_object (&kernel_object_store) #define kmem_object (&kmem_object_store) -#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, type) \ - mtx_init(&(object)->mtx, "vm object", \ - (type), MTX_DEF | MTX_DUPOK) -#define VM_OBJECT_LOCKED(object) mtx_owned(&(object)->mtx) -#define VM_OBJECT_MTX(object) (&(object)->mtx) -#define VM_OBJECT_TRYLOCK(object) mtx_trylock(&(object)->mtx) -#define VM_OBJECT_UNLOCK(object) mtx_unlock(&(object)->mtx) +#define VM_OBJECT_LOCK(object) \ + rw_wlock(&(object)->lock) +#define VM_OBJECT_LOCK_ASSERT(object, type) \ + rw_assert(&(object)->lock, (type)) +#define VM_OBJECT_LOCK_INIT(object, name) \ + rw_init_flags(&(object)->lock, (name), RW_DUPOK) +#define VM_OBJECT_LOCKED(object) \ + rw_wowned(&(object)->lock) +#define VM_OBJECT_LOCKPTR(object) \ + (&(object)->lock) +#define VM_OBJECT_SLEEP(wchan, object, pri, wmesg, timo) \ + rw_sleep((wchan), &(object)->lock, (pri), (wmesg), (timo)) +#define VM_OBJECT_TRYLOCK(object) \ + rw_try_wlock(&(object)->lock) +#define VM_OBJECT_UNLOCK(object) \ + rw_wunlock(&(object)->lock) /* * The object must be locked or thread private. |