summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-01-24 11:28:36 +0000
committerjhb <jhb@FreeBSD.org>2001-01-24 11:28:36 +0000
commit9d4ef4f19ca6838d213df7f6ac04590336afa71c (patch)
tree4701144de3162995d8b6aa49cf7753386f36b29f /sys
parentf2190e5fefd4fa7add666dfdb775beae244d46f4 (diff)
downloadFreeBSD-src-9d4ef4f19ca6838d213df7f6ac04590336afa71c.zip
FreeBSD-src-9d4ef4f19ca6838d213df7f6ac04590336afa71c.tar.gz
- Catch up to proc flag changes.
- Minimal proc locking. - Use queue macros.
Diffstat (limited to 'sys')
-rw-r--r--sys/vm/vm_meter.c21
-rw-r--r--sys/vm/vm_pageout.c11
2 files changed, 21 insertions, 11 deletions
diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c
index 2fa0754..d0283ba 100644
--- a/sys/vm/vm_meter.c
+++ b/sys/vm/vm_meter.c
@@ -144,33 +144,35 @@ vmtotal(SYSCTL_HANDLER_ARGS)
/*
* Mark all objects as inactive.
*/
- for (object = TAILQ_FIRST(&vm_object_list);
- object != NULL;
- object = TAILQ_NEXT(object,object_list))
+ TAILQ_FOREACH(object, &vm_object_list, object_list)
vm_object_clear_flag(object, OBJ_ACTIVE);
/*
* Calculate process statistics.
*/
ALLPROC_LOCK(AP_SHARED);
- for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
+ LIST_FOREACH(p, &allproc, p_list) {
if (p->p_flag & P_SYSTEM)
continue;
+ mtx_enter(&sched_lock, MTX_SPIN);
switch (p->p_stat) {
case 0:
+ mtx_exit(&sched_lock, MTX_SPIN);
continue;
case SMTX:
case SSLEEP:
case SSTOP:
- if (p->p_flag & P_INMEM) {
+ if (p->p_sflag & PS_INMEM) {
if (p->p_priority <= PZERO)
totalp->t_dw++;
else if (p->p_slptime < maxslp)
totalp->t_sl++;
} else if (p->p_slptime < maxslp)
totalp->t_sw++;
- if (p->p_slptime >= maxslp)
+ if (p->p_slptime >= maxslp) {
+ mtx_exit(&sched_lock, MTX_SPIN);
continue;
+ }
break;
case SWAIT:
@@ -179,14 +181,17 @@ vmtotal(SYSCTL_HANDLER_ARGS)
case SRUN:
case SIDL:
- if (p->p_flag & P_INMEM)
+ if (p->p_sflag & PS_INMEM)
totalp->t_rq++;
else
totalp->t_sw++;
- if (p->p_stat == SIDL)
+ if (p->p_stat == SIDL) {
+ mtx_exit(&sched_lock, MTX_SPIN);
continue;
+ }
break;
}
+ mtx_exit(&sched_lock, MTX_SPIN);
/*
* Note active objects.
*/
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
index 943fb11..0dd7ecb 100644
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -1124,15 +1124,18 @@ rescan0:
bigproc = NULL;
bigsize = 0;
ALLPROC_LOCK(AP_SHARED);
- for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
+ LIST_FOREACH(p, &allproc, p_list) {
/*
* if this is a system process, skip it
*/
+ PROC_LOCK(p);
if ((p->p_flag & P_SYSTEM) || (p->p_lock > 0) ||
(p->p_pid == 1) ||
((p->p_pid < 48) && (vm_swap_size != 0))) {
+ PROC_UNLOCK(p);
continue;
}
+ PROC_UNLOCK(p);
/*
* if the process is in a non-running type state,
* don't touch it.
@@ -1159,9 +1162,11 @@ rescan0:
ALLPROC_LOCK(AP_RELEASE);
if (bigproc != NULL) {
killproc(bigproc, "out of swap space");
+ mtx_enter(&sched_lock, MTX_SPIN);
bigproc->p_estcpu = 0;
bigproc->p_nice = PRIO_MIN;
resetpriority(bigproc);
+ mtx_exit(&sched_lock, MTX_SPIN);
wakeup(&cnt.v_free_count);
}
}
@@ -1477,7 +1482,6 @@ vm_daemon()
mtx_exit(&sched_lock, MTX_SPIN);
continue;
}
- mtx_exit(&sched_lock, MTX_SPIN);
/*
* get a limit
*/
@@ -1490,8 +1494,9 @@ vm_daemon()
* swapped out set the limit to nothing (will force a
* swap-out.)
*/
- if ((p->p_flag & P_INMEM) == 0)
+ if ((p->p_sflag & PS_INMEM) == 0)
limit = 0; /* XXX */
+ mtx_exit(&sched_lock, MTX_SPIN);
size = vmspace_resident_count(p->p_vmspace);
if (limit >= 0 && size >= limit) {
OpenPOWER on IntegriCloud