summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_glue.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2000-12-02 03:29:33 +0000
committerjhb <jhb@FreeBSD.org>2000-12-02 03:29:33 +0000
commitb8b5877ce71b73b0e5e40cc962657bdbfda427e0 (patch)
treeb1058eed07d064a0ade0a15485d433500fb4ba66 /sys/vm/vm_glue.c
parente72e697e0d3ce757fe16352fc66bf2320a2ec693 (diff)
downloadFreeBSD-src-b8b5877ce71b73b0e5e40cc962657bdbfda427e0.zip
FreeBSD-src-b8b5877ce71b73b0e5e40cc962657bdbfda427e0.tar.gz
Protect p_stat with sched_lock.
Diffstat (limited to 'sys/vm/vm_glue.c')
-rw-r--r--sys/vm/vm_glue.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c
index 3c9e941..3bc4d11 100644
--- a/sys/vm/vm_glue.c
+++ b/sys/vm/vm_glue.c
@@ -362,6 +362,7 @@ loop:
ppri = INT_MIN;
lockmgr(&allproc_lock, LK_SHARED, NULL, CURPROC);
for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
+ mtx_enter(&sched_lock, MTX_SPIN);
if (p->p_stat == SRUN &&
(p->p_flag & (P_INMEM | P_SWAPPING)) == 0) {
@@ -380,6 +381,7 @@ loop:
ppri = pri;
}
}
+ mtx_exit(&sched_lock, MTX_SPIN);
}
lockmgr(&allproc_lock, LK_RELEASE, NULL, CURPROC);
@@ -450,8 +452,10 @@ retry:
vm = p->p_vmspace;
+ mtx_enter(&sched_lock, MTX_SPIN);
switch (p->p_stat) {
default:
+ mtx_exit(&sched_lock, MTX_SPIN);
continue;
case SSLEEP:
@@ -459,8 +463,10 @@ retry:
/*
* do not swapout a realtime process
*/
- if (RTP_PRIO_IS_REALTIME(p->p_rtprio.type))
+ if (RTP_PRIO_IS_REALTIME(p->p_rtprio.type)) {
+ mtx_exit(&sched_lock, MTX_SPIN);
continue;
+ }
/*
* Do not swapout a process waiting on a critical
@@ -468,8 +474,11 @@ retry:
* time in memory.
*/
if (((p->p_priority & 0x7f) < PSOCK) ||
- (p->p_slptime < swap_idle_threshold1))
+ (p->p_slptime < swap_idle_threshold1)) {
+ mtx_exit(&sched_lock, MTX_SPIN);
continue;
+ }
+ mtx_exit(&sched_lock, MTX_SPIN);
/*
* If the system is under memory stress, or if we are swapping
@@ -531,10 +540,12 @@ swapout(p)
p->p_vmspace->vm_swrss = vmspace_resident_count(p->p_vmspace);
(void) splhigh();
+ mtx_enter(&sched_lock, MTX_SPIN);
p->p_flag &= ~P_INMEM;
p->p_flag |= P_SWAPPING;
if (p->p_stat == SRUN)
remrunqueue(p);
+ mtx_exit(&sched_lock, MTX_SPIN);
(void) spl0();
pmap_swapout_proc(p);
OpenPOWER on IntegriCloud