summaryrefslogtreecommitdiff
path: root/sys/vm/vm_glue.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2002-10-22 14:31:32 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2002-10-22 14:31:32 +0000
commit1c865ac70ef2e45e2b1419bb98486a7a5946c7bb (patch)
tree3f0780de13f7fe9cb1e932841a02cd504712e560 /sys/vm/vm_glue.c
parentf7b951a8e064b154af60890761a52cdfcaf5761e (diff)
Notes
Diffstat (limited to 'sys/vm/vm_glue.c')
-rw-r--r--sys/vm/vm_glue.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c
index 0f9951297774..6ac6a96688aa 100644
--- a/sys/vm/vm_glue.c
+++ b/sys/vm/vm_glue.c
@@ -660,21 +660,18 @@ retry:
int minslptime = 100000;
/*
- * Do not swapout a process that
- * is waiting for VM data
- * structures there is a possible
- * deadlock. Test this first as
- * this may block.
- *
- * Lock the map until swapout
- * finishes, or a thread of this
- * process may attempt to alter
- * the map.
- *
* Watch out for a process in
* creation. It may have no
- * address space yet.
- *
+ * address space or lock yet.
+ */
+ mtx_lock_spin(&sched_lock);
+ if (p->p_state == PRS_NEW) {
+ mtx_unlock_spin(&sched_lock);
+ continue;
+ }
+ mtx_unlock_spin(&sched_lock);
+
+ /*
* An aio daemon switches its
* address space while running.
* Perform a quick check whether
@@ -685,17 +682,23 @@ retry:
PROC_UNLOCK(p);
continue;
}
- mtx_lock_spin(&sched_lock);
- if (p->p_state == PRS_NEW) {
- mtx_unlock_spin(&sched_lock);
- PROC_UNLOCK(p);
- continue;
- }
+
+ /*
+ * Do not swapout a process that
+ * is waiting for VM data
+ * structures as there is a possible
+ * deadlock. Test this first as
+ * this may block.
+ *
+ * Lock the map until swapout
+ * finishes, or a thread of this
+ * process may attempt to alter
+ * the map.
+ */
vm = p->p_vmspace;
KASSERT(vm != NULL,
("swapout_procs: a process has no address space"));
++vm->vm_refcnt;
- mtx_unlock_spin(&sched_lock);
PROC_UNLOCK(p);
if (!vm_map_trylock(&vm->vm_map))
goto nextproc1;