summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_glue.c
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2007-09-21 05:07:07 +0000
committerjeff <jeff@FreeBSD.org>2007-09-21 05:07:07 +0000
commite132f56a452fd722d5cc15f703c269b40fcc87b4 (patch)
tree0a75a0e28b3f2961cae88607eabece92179c45df /sys/vm/vm_glue.c
parent22dc0ec6a9f3f21ca6f415759b905217ed587aff (diff)
downloadFreeBSD-src-e132f56a452fd722d5cc15f703c269b40fcc87b4.zip
FreeBSD-src-e132f56a452fd722d5cc15f703c269b40fcc87b4.tar.gz
- 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
Diffstat (limited to 'sys/vm/vm_glue.c')
-rw-r--r--sys/vm/vm_glue.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c
index 6e4f42d..caa8aa0 100644
--- a/sys/vm/vm_glue.c
+++ b/sys/vm/vm_glue.c
@@ -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 */
OpenPOWER on IntegriCloud