- Catch up to proc flag changes.

- Minimal proc locking.
- Use queue macros.
This commit is contained in:
jhb 2001-01-24 11:28:36 +00:00
parent f2190e5fef
commit 9d4ef4f19c
2 changed files with 21 additions and 11 deletions

View File

@ -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.
*/

View File

@ -1124,15 +1124,18 @@ vm_pageout_scan(int pass)
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 @@ vm_pageout_scan(int pass)
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) {