diff options
author | attilio <attilio@FreeBSD.org> | 2013-05-21 20:38:19 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2013-05-21 20:38:19 +0000 |
commit | fdf82ef9cfb84888e76e303fe6c9ee30fbc21d1e (patch) | |
tree | 24458ef5e2585280bf95280f83f977fde60faeaa /sys/vm | |
parent | 05bd8275f3829e7d1f55e8faabd64095eab3c291 (diff) | |
download | FreeBSD-src-fdf82ef9cfb84888e76e303fe6c9ee30fbc21d1e.zip FreeBSD-src-fdf82ef9cfb84888e76e303fe6c9ee30fbc21d1e.tar.gz |
o Relax locking assertions for vm_page_find_least()
o Relax locking assertions for pmap_enter_object() and add them also
to architectures that currently don't have any
o Introduce VM_OBJECT_LOCK_DOWNGRADE() which is basically a downgrade
operation on the per-object rwlock
o Use all the mechanisms above to make vm_map_pmap_enter() to work
mostl of the times only with readlocks.
Sponsored by: EMC / Isilon storage division
Reviewed by: alc
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_map.c | 22 | ||||
-rw-r--r-- | sys/vm/vm_object.h | 2 | ||||
-rw-r--r-- | sys/vm/vm_page.c | 2 |
3 files changed, 18 insertions, 8 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 933b0e1..a9ae803 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -1806,18 +1806,27 @@ vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, if ((prot & (VM_PROT_READ | VM_PROT_EXECUTE)) == 0 || object == NULL) return; - VM_OBJECT_WLOCK(object); + VM_OBJECT_RLOCK(object); if (object->type == OBJT_DEVICE || object->type == OBJT_SG) { - pmap_object_init_pt(map->pmap, addr, object, pindex, size); - goto unlock_return; + VM_OBJECT_RUNLOCK(object); + VM_OBJECT_WLOCK(object); + if (object->type == OBJT_DEVICE || object->type == OBJT_SG) { + pmap_object_init_pt(map->pmap, addr, object, pindex, + size); + VM_OBJECT_WUNLOCK(object); + return; + } + VM_OBJECT_LOCK_DOWNGRADE(object); } psize = atop(size); if (psize > MAX_INIT_PT && (flags & MAP_PREFAULT_PARTIAL) != 0) psize = MAX_INIT_PT; if (psize + pindex > object->size) { - if (object->size < pindex) - goto unlock_return; + if (object->size < pindex) { + VM_OBJECT_RUNLOCK(object); + return; + } psize = object->size - pindex; } @@ -1856,8 +1865,7 @@ vm_map_pmap_enter(vm_map_t map, vm_offset_t addr, vm_prot_t prot, if (p_start != NULL) pmap_enter_object(map->pmap, start, addr + ptoa(psize), p_start, prot); -unlock_return: - VM_OBJECT_WUNLOCK(object); + VM_OBJECT_RUNLOCK(object); } /* diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index cf54663..05ab73d 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -223,6 +223,8 @@ extern struct vm_object kmem_object_store; rw_assert(&(object)->lock, RA_RLOCKED) #define VM_OBJECT_ASSERT_WLOCKED(object) \ rw_assert(&(object)->lock, RA_WLOCKED) +#define VM_OBJECT_LOCK_DOWNGRADE(object) \ + rw_downgrade(&(object)->lock) #define VM_OBJECT_RLOCK(object) \ rw_rlock(&(object)->lock) #define VM_OBJECT_RUNLOCK(object) \ diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 637fb0c..15697c9 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -959,7 +959,7 @@ vm_page_find_least(vm_object_t object, vm_pindex_t pindex) { vm_page_t m; - VM_OBJECT_ASSERT_WLOCKED(object); + VM_OBJECT_ASSERT_LOCKED(object); if ((m = TAILQ_FIRST(&object->memq)) != NULL && m->pindex < pindex) m = vm_radix_lookup_ge(&object->rtree, pindex); return (m); |