summaryrefslogtreecommitdiffstats
path: root/sys/vm
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2011-11-20 16:33:09 +0000
committerattilio <attilio@FreeBSD.org>2011-11-20 16:33:09 +0000
commit6a69e947d3eb5ffaceb04f999c1925ed771b7546 (patch)
tree1fcde0be5ef74d1581c3a825bc7f36ff5d1c05b3 /sys/vm
parentbf5f03ca46a93268d5d0eccc7318039bda9106d2 (diff)
downloadFreeBSD-src-6a69e947d3eb5ffaceb04f999c1925ed771b7546.zip
FreeBSD-src-6a69e947d3eb5ffaceb04f999c1925ed771b7546.tar.gz
Introduce macro stubs in the mutex implementation that will be always
defined and will allow consumers, willing to provide options, file and line to locking requests, to not worry about options redefining the interfaces. This is typically useful when there is the need to build another locking interface on top of the mutex one. The introduced functions that consumers can use are: - mtx_lock_flags_ - mtx_unlock_flags_ - mtx_lock_spin_flags_ - mtx_unlock_spin_flags_ - mtx_assert_ - thread_lock_flags_ Spare notes: - Likely we can get rid of all the 'INVARIANTS' specification in the ppbus code by using the same macro as done in this patch (but this is left to the ppbus maintainer) - all the other locking interfaces may require a similar cleanup, where the most notable case is sx which will allow a further cleanup of vm_map locking facilities - The patch should be fully compatible with older branches, thus a MFC is previewed (infact it uses all the underlying mechanisms already present). Comments review by: eadler, Ben Kaduk Discussed with: kib, jhb MFC after: 1 month
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/vm_map.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index 8493478..962ae9c 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -464,7 +464,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);
+ mtx_lock_flags_(&map->system_mtx, 0, file, line);
else
(void)_sx_xlock(&map->lock, 0, file, line);
map->timestamp++;
@@ -489,7 +489,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);
+ mtx_unlock_flags_(&map->system_mtx, 0, file, line);
else {
_sx_xunlock(&map->lock, file, line);
vm_map_process_deferred();
@@ -501,7 +501,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);
+ mtx_lock_flags_(&map->system_mtx, 0, file, line);
else
(void)_sx_slock(&map->lock, 0, file, line);
}
@@ -511,7 +511,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);
+ mtx_unlock_flags_(&map->system_mtx, 0, file, line);
else {
_sx_sunlock(&map->lock, file, line);
vm_map_process_deferred();
@@ -524,7 +524,7 @@ _vm_map_trylock(vm_map_t map, const char *file, int line)
int error;
error = map->system_map ?
- !_mtx_trylock(&map->system_mtx, 0, file, line) :
+ !mtx_trylock_flags_(&map->system_mtx, 0, file, line) :
!_sx_try_xlock(&map->lock, file, line);
if (error == 0)
map->timestamp++;
@@ -537,7 +537,7 @@ _vm_map_trylock_read(vm_map_t map, const char *file, int line)
int error;
error = map->system_map ?
- !_mtx_trylock(&map->system_mtx, 0, file, line) :
+ !mtx_trylock_flags_(&map->system_mtx, 0, file, line) :
!_sx_try_slock(&map->lock, file, line);
return (error == 0);
}
@@ -558,9 +558,7 @@ _vm_map_lock_upgrade(vm_map_t map, const char *file, int line)
unsigned int last_timestamp;
if (map->system_map) {
-#ifdef INVARIANTS
- _mtx_assert(&map->system_mtx, MA_OWNED, file, line);
-#endif
+ mtx_assert_(&map->system_mtx, MA_OWNED, file, line);
} else {
if (!_sx_try_upgrade(&map->lock, file, line)) {
last_timestamp = map->timestamp;
@@ -586,9 +584,7 @@ _vm_map_lock_downgrade(vm_map_t map, const char *file, int line)
{
if (map->system_map) {
-#ifdef INVARIANTS
- _mtx_assert(&map->system_mtx, MA_OWNED, file, line);
-#endif
+ mtx_assert_(&map->system_mtx, MA_OWNED, file, line);
} else
_sx_downgrade(&map->lock, file, line);
}
@@ -609,13 +605,14 @@ 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)
{
if (map->system_map)
- _mtx_assert(&map->system_mtx, MA_OWNED, file, line);
+ mtx_assert_(&map->system_mtx, MA_OWNED, file, line);
else
_sx_assert(&map->lock, SA_XLOCKED, file, line);
}
@@ -626,7 +623,7 @@ _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);
+ mtx_assert_(&map->system_mtx, MA_OWNED, file, line);
else
_sx_assert(&map->lock, SA_SLOCKED, file, line);
}
@@ -661,7 +658,7 @@ _vm_map_unlock_and_wait(vm_map_t map, int timo, const char *file, int line)
mtx_lock(&map_sleep_mtx);
if (map->system_map)
- _mtx_unlock_flags(&map->system_mtx, 0, file, line);
+ mtx_unlock_flags_(&map->system_mtx, 0, file, line);
else
_sx_xunlock(&map->lock, file, line);
return (msleep(&map->root, &map_sleep_mtx, PDROP | PVM, "vmmaps",
OpenPOWER on IntegriCloud