summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_map.c
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2003-03-12 23:13:16 +0000
committerdas <das@FreeBSD.org>2003-03-12 23:13:16 +0000
commit96f973e7de4d8f2a11ecedfae50b316319fd1026 (patch)
tree6cae5d8751656edd0c9fcd23480226ea6d6747ec /sys/vm/vm_map.c
parenteb02bdf56a079dea8449cdfa53c66a3d36496504 (diff)
downloadFreeBSD-src-96f973e7de4d8f2a11ecedfae50b316319fd1026.zip
FreeBSD-src-96f973e7de4d8f2a11ecedfae50b316319fd1026.tar.gz
- When the VM daemon is out of swap space and looking for a
process to kill, don't block on a map lock while holding the process lock. Instead, skip processes whose map locks are held and find something else to kill. - Add vm_map_trylock_read() to support the above. Reviewed by: alc, mike (mentor)
Diffstat (limited to 'sys/vm/vm_map.c')
-rw-r--r--sys/vm/vm_map.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index 33e819d..6e96db3 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -346,6 +346,8 @@ vmspace_exitfree(struct proc *p)
* vmspace_swap_count() - count the approximate swap useage in pages for a
* vmspace.
*
+ * The map must be locked.
+ *
* Swap useage is determined by taking the proportional swap used by
* VM objects backing the VM map. To make up for fractional losses,
* if the VM object has any swap use at all the associated map entries
@@ -358,7 +360,6 @@ vmspace_swap_count(struct vmspace *vmspace)
vm_map_entry_t cur;
int count = 0;
- vm_map_lock_read(map);
for (cur = map->header.next; cur != &map->header; cur = cur->next) {
vm_object_t object;
@@ -374,7 +375,6 @@ vmspace_swap_count(struct vmspace *vmspace)
}
}
}
- vm_map_unlock_read(map);
return (count);
}
@@ -439,6 +439,17 @@ _vm_map_trylock(vm_map_t map, const char *file, int line)
}
int
+_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) :
+ lockmgr(&map->lock, LK_EXCLUSIVE | LK_NOWAIT, NULL, curthread);
+ return (error == 0);
+}
+
+int
_vm_map_lock_upgrade(vm_map_t map, const char *file, int line)
{
OpenPOWER on IntegriCloud