diff options
author | attilio <attilio@FreeBSD.org> | 2011-11-21 12:59:52 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2011-11-21 12:59:52 +0000 |
commit | b95134ea01e46b282074a03ea01be1fc9d95a328 (patch) | |
tree | 40b25c5a1fa8695b73e18ea776cf41e1418873fd /sys/vm | |
parent | 3aadfef0044607b2474ae1bba0c2fca2b37e18e3 (diff) | |
download | FreeBSD-src-b95134ea01e46b282074a03ea01be1fc9d95a328.zip FreeBSD-src-b95134ea01e46b282074a03ea01be1fc9d95a328.tar.gz |
Introduce the same mutex-wise fix in r227758 for sx locks.
The functions that offer file and line specifications are:
- sx_assert_
- sx_downgrade_
- sx_slock_
- sx_slock_sig_
- sx_sunlock_
- sx_try_slock_
- sx_try_xlock_
- sx_try_upgrade_
- sx_unlock_
- sx_xlock_
- sx_xlock_sig_
- sx_xunlock_
Now vm_map locking is fully converted and can avoid to know specifics
about locking procedures.
Reviewed by: kib
MFC after: 1 month
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_map.c | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 962ae9c..d62576f 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -466,7 +466,7 @@ _vm_map_lock(vm_map_t map, const char *file, int line) if (map->system_map) mtx_lock_flags_(&map->system_mtx, 0, file, line); else - (void)_sx_xlock(&map->lock, 0, file, line); + sx_xlock_(&map->lock, file, line); map->timestamp++; } @@ -491,7 +491,7 @@ _vm_map_unlock(vm_map_t map, const char *file, int line) if (map->system_map) mtx_unlock_flags_(&map->system_mtx, 0, file, line); else { - _sx_xunlock(&map->lock, file, line); + sx_xunlock_(&map->lock, file, line); vm_map_process_deferred(); } } @@ -503,7 +503,7 @@ _vm_map_lock_read(vm_map_t map, const char *file, int line) if (map->system_map) mtx_lock_flags_(&map->system_mtx, 0, file, line); else - (void)_sx_slock(&map->lock, 0, file, line); + sx_slock_(&map->lock, file, line); } void @@ -513,7 +513,7 @@ _vm_map_unlock_read(vm_map_t map, const char *file, int line) if (map->system_map) mtx_unlock_flags_(&map->system_mtx, 0, file, line); else { - _sx_sunlock(&map->lock, file, line); + sx_sunlock_(&map->lock, file, line); vm_map_process_deferred(); } } @@ -525,7 +525,7 @@ _vm_map_trylock(vm_map_t map, const char *file, int line) error = map->system_map ? !mtx_trylock_flags_(&map->system_mtx, 0, file, line) : - !_sx_try_xlock(&map->lock, file, line); + !sx_try_xlock_(&map->lock, file, line); if (error == 0) map->timestamp++; return (error == 0); @@ -538,7 +538,7 @@ _vm_map_trylock_read(vm_map_t map, const char *file, int line) error = map->system_map ? !mtx_trylock_flags_(&map->system_mtx, 0, file, line) : - !_sx_try_slock(&map->lock, file, line); + !sx_try_slock_(&map->lock, file, line); return (error == 0); } @@ -560,17 +560,17 @@ _vm_map_lock_upgrade(vm_map_t map, const char *file, int line) if (map->system_map) { mtx_assert_(&map->system_mtx, MA_OWNED, file, line); } else { - if (!_sx_try_upgrade(&map->lock, file, line)) { + if (!sx_try_upgrade_(&map->lock, file, line)) { last_timestamp = map->timestamp; - _sx_sunlock(&map->lock, file, line); + sx_sunlock_(&map->lock, file, line); vm_map_process_deferred(); /* * If the map's timestamp does not change while the * map is unlocked, then the upgrade succeeds. */ - (void)_sx_xlock(&map->lock, 0, file, line); + sx_xlock_(&map->lock, file, line); if (last_timestamp != map->timestamp) { - _sx_xunlock(&map->lock, file, line); + sx_xunlock_(&map->lock, file, line); return (1); } } @@ -586,7 +586,7 @@ _vm_map_lock_downgrade(vm_map_t map, const char *file, int line) if (map->system_map) { mtx_assert_(&map->system_mtx, MA_OWNED, file, line); } else - _sx_downgrade(&map->lock, file, line); + sx_downgrade_(&map->lock, file, line); } /* @@ -605,7 +605,6 @@ vm_map_locked(vm_map_t map) return (sx_xlocked(&map->lock)); } -/* XXX: INVARIANTS here is still necessary because of sx support. */ #ifdef INVARIANTS static void _vm_map_assert_locked(vm_map_t map, const char *file, int line) @@ -614,28 +613,13 @@ _vm_map_assert_locked(vm_map_t map, const char *file, int line) if (map->system_map) mtx_assert_(&map->system_mtx, MA_OWNED, file, line); else - _sx_assert(&map->lock, SA_XLOCKED, file, line); + sx_assert_(&map->lock, SA_XLOCKED, file, line); } -#if 0 -static void -_vm_map_assert_locked_read(vm_map_t map, const char *file, int line) -{ - - if (map->system_map) - mtx_assert_(&map->system_mtx, MA_OWNED, file, line); - else - _sx_assert(&map->lock, SA_SLOCKED, file, line); -} -#endif - #define VM_MAP_ASSERT_LOCKED(map) \ _vm_map_assert_locked(map, LOCK_FILE, LOCK_LINE) -#define VM_MAP_ASSERT_LOCKED_READ(map) \ - _vm_map_assert_locked_read(map, LOCK_FILE, LOCK_LINE) #else #define VM_MAP_ASSERT_LOCKED(map) -#define VM_MAP_ASSERT_LOCKED_READ(map) #endif /* @@ -660,7 +644,7 @@ _vm_map_unlock_and_wait(vm_map_t map, int timo, const char *file, int line) if (map->system_map) mtx_unlock_flags_(&map->system_mtx, 0, file, line); else - _sx_xunlock(&map->lock, file, line); + sx_xunlock_(&map->lock, file, line); return (msleep(&map->root, &map_sleep_mtx, PDROP | PVM, "vmmaps", timo)); } |