diff options
author | alc <alc@FreeBSD.org> | 2002-12-30 00:41:33 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 2002-12-30 00:41:33 +0000 |
commit | bc746e81d26e2998dcade4f9b9be21cdf5f1ab48 (patch) | |
tree | 1aa5bbe5f21c40be8e64300bf061ed92ef384803 /sys/vm/vm_map.c | |
parent | be7461fd3fb433cd819129bdd5144d08f52d5d81 (diff) | |
download | FreeBSD-src-bc746e81d26e2998dcade4f9b9be21cdf5f1ab48.zip FreeBSD-src-bc746e81d26e2998dcade4f9b9be21cdf5f1ab48.tar.gz |
- Increment the vm_map's timestamp if _vm_map_trylock() succeeds.
- Introduce map_sleep_mtx and use it to replace Giant in
vm_map_unlock_and_wait() and vm_map_wakeup(). (Original
version by: tegge.)
Diffstat (limited to 'sys/vm/vm_map.c')
-rw-r--r-- | sys/vm/vm_map.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 179c0e0..2b4c667 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -133,6 +133,7 @@ * maps and requires map entries. */ +static struct mtx map_sleep_mtx; static uma_zone_t mapentzone; static uma_zone_t kmapentzone; static uma_zone_t mapzone; @@ -152,6 +153,7 @@ static void vmspace_zdtor(void *mem, int size, void *arg); void vm_map_startup(void) { + mtx_init(&map_sleep_mtx, "vm map sleep mutex", NULL, MTX_DEF); mapzone = uma_zcreate("MAP", sizeof(struct vm_map), NULL, #ifdef INVARIANTS vm_map_zdtor, @@ -412,6 +414,8 @@ _vm_map_trylock(vm_map_t map, const char *file, int line) if (map->system_map) GIANT_REQUIRED; error = lockmgr(&map->lock, LK_EXCLUSIVE | LK_NOWAIT, NULL, curthread); + if (error == 0) + map->timestamp++; return (error == 0); } @@ -439,13 +443,10 @@ _vm_map_lock_downgrade(vm_map_t map, const char *file, int line) int vm_map_unlock_and_wait(vm_map_t map, boolean_t user_wait) { - int retval; - mtx_lock(&Giant); + mtx_lock(&map_sleep_mtx); vm_map_unlock(map); - retval = tsleep(&map->root, PVM, "vmmapw", 0); - mtx_unlock(&Giant); - return (retval); + return (msleep(&map->root, &map_sleep_mtx, PDROP | PVM, "vmmaps", 0)); } /* @@ -456,12 +457,12 @@ vm_map_wakeup(vm_map_t map) { /* - * Acquire and release Giant to prevent a wakeup() from being - * performed (and lost) between the vm_map_unlock() and the - * tsleep() in vm_map_unlock_and_wait(). + * Acquire and release map_sleep_mtx to prevent a wakeup() + * from being performed (and lost) between the vm_map_unlock() + * and the msleep() in vm_map_unlock_and_wait(). */ - mtx_lock(&Giant); - mtx_unlock(&Giant); + mtx_lock(&map_sleep_mtx); + mtx_unlock(&map_sleep_mtx); wakeup(&map->root); } |