- Redefine p_swtime and td_slptime as p_swtick and td_slptick. This
changes the units from seconds to the value of 'ticks' when swapped in/out. ULE does not have a periodic timer that scans all threads in the system and as such maintaining a per-second counter is difficult. - Change computations requiring the unit in seconds to subtract ticks and divide by hz. This does make the wraparound condition hz times more frequent but this is still in the range of several months to years and the adverse effects are minimal. Approved by: re
This commit is contained in:
parent
016e328d16
commit
258853ab1c
@ -636,7 +636,7 @@ faultin(p)
|
||||
PROC_LOCK(p);
|
||||
PROC_SLOCK(p);
|
||||
swapclear(p);
|
||||
p->p_swtime = 0;
|
||||
p->p_swtick = ticks;
|
||||
PROC_SUNLOCK(p);
|
||||
|
||||
wakeup(&p->p_flag);
|
||||
@ -663,9 +663,11 @@ scheduler(dummy)
|
||||
{
|
||||
struct proc *p;
|
||||
struct thread *td;
|
||||
int pri;
|
||||
struct proc *pp;
|
||||
int slptime;
|
||||
int swtime;
|
||||
int ppri;
|
||||
int pri;
|
||||
|
||||
mtx_assert(&Giant, MA_OWNED | MA_NOTRECURSED);
|
||||
mtx_unlock(&Giant);
|
||||
@ -688,6 +690,7 @@ loop:
|
||||
PROC_UNLOCK(p);
|
||||
continue;
|
||||
}
|
||||
swtime = (ticks - p->p_swtick) / hz;
|
||||
PROC_SLOCK(p);
|
||||
FOREACH_THREAD_IN_PROC(p, td) {
|
||||
/*
|
||||
@ -697,7 +700,8 @@ loop:
|
||||
*/
|
||||
thread_lock(td);
|
||||
if (td->td_inhibitors == TDI_SWAPPED) {
|
||||
pri = p->p_swtime + td->td_slptime;
|
||||
slptime = (ticks - td->td_slptick) / hz;
|
||||
pri = swtime + slptime;
|
||||
if ((td->td_flags & TDF_SWAPINREQ) == 0)
|
||||
pri -= p->p_nice * 8;
|
||||
/*
|
||||
@ -816,6 +820,7 @@ retry:
|
||||
FOREACH_PROC_IN_SYSTEM(p) {
|
||||
struct vmspace *vm;
|
||||
int minslptime = 100000;
|
||||
int slptime;
|
||||
|
||||
/*
|
||||
* Watch out for a process in
|
||||
@ -882,12 +887,12 @@ retry:
|
||||
thread_unlock(td);
|
||||
goto nextproc;
|
||||
}
|
||||
|
||||
slptime = (ticks - td->td_slptick) / hz;
|
||||
/*
|
||||
* Guarantee swap_idle_threshold1
|
||||
* time in memory.
|
||||
*/
|
||||
if (td->td_slptime < swap_idle_threshold1) {
|
||||
if (slptime < swap_idle_threshold1) {
|
||||
thread_unlock(td);
|
||||
goto nextproc;
|
||||
}
|
||||
@ -914,13 +919,13 @@ retry:
|
||||
*/
|
||||
if (((action & VM_SWAP_NORMAL) == 0) &&
|
||||
(((action & VM_SWAP_IDLE) == 0) ||
|
||||
(td->td_slptime < swap_idle_threshold2))) {
|
||||
(slptime < swap_idle_threshold2))) {
|
||||
thread_unlock(td);
|
||||
goto nextproc;
|
||||
}
|
||||
|
||||
if (minslptime > td->td_slptime)
|
||||
minslptime = td->td_slptime;
|
||||
if (minslptime > slptime)
|
||||
minslptime = slptime;
|
||||
thread_unlock(td);
|
||||
}
|
||||
|
||||
@ -1038,7 +1043,7 @@ swapout(p)
|
||||
PROC_LOCK(p);
|
||||
p->p_flag &= ~P_SWAPPINGOUT;
|
||||
PROC_SLOCK(p);
|
||||
p->p_swtime = 0;
|
||||
p->p_swtick = ticks;
|
||||
return (0);
|
||||
}
|
||||
#endif /* !NO_SWAPPING */
|
||||
|
Loading…
x
Reference in New Issue
Block a user