Index: kern/subr_pidctrl.c =================================================================== --- kern/subr_pidctrl.c +++ kern/subr_pidctrl.c @@ -112,13 +112,32 @@ return (output); } +static int counter; +SYSCTL_INT(_debug, OID_AUTO, counter, CTLFLAG_RD, &counter, 0, ""); + +static int counter1; +SYSCTL_INT(_debug, OID_AUTO, counter1, CTLFLAG_RD, &counter1, 0, ""); + +static u_int foo1; +SYSCTL_UINT(_debug, OID_AUTO, foo1, CTLFLAG_RD, &foo1, 0, ""); + +static u_int foo2; +SYSCTL_UINT(_debug, OID_AUTO, foo2, CTLFLAG_RD, &foo2, 0, ""); + int pidctrl_daemon(struct pidctrl *pc, int input) { - int output, error; + int output, error, tick; int Kpd, Kid, Kdd; error = pc->pc_setpoint - input; + tick = ticks; +foo1 = tick; +foo2 = pc->pc_ticks; + if (tick == pc->pc_ticks - 1) { + tick++; +counter1++; + } /* * When ticks expires we reset our variables and start a new * interval. If we're called multiple times during one interval @@ -125,13 +144,14 @@ * we attempt to report a target as if the entire error came at * the interval boundary. */ - if ((u_int)ticks - pc->pc_ticks >= pc->pc_interval) { - pc->pc_ticks = ticks; + if ((u_int)tick >= pc->pc_ticks) { + pc->pc_ticks = roundup((u_int)tick + 1, pc->pc_interval); pc->pc_olderror = pc->pc_error; pc->pc_output = pc->pc_error = 0; } else { /* Calculate the error relative to the last call. */ error -= pc->pc_error - pc->pc_output; +counter++; } /* Fetch gains and prevent divide by zero. */ Index: vm/vm_pageout.c =================================================================== --- vm/vm_pageout.c +++ vm/vm_pageout.c @@ -1867,15 +1867,19 @@ } } +static int dt; +SYSCTL_INT(_debug, OID_AUTO, dt, CTLFLAG_RD, &dt, 0, ""); + static void vm_pageout_worker(void *arg) { struct vm_domain *vmd; - int addl_shortage, domain, shortage; + int addl_shortage, domain, period, shortage; bool target_met; domain = (uintptr_t)arg; vmd = VM_DOMAIN(domain); + period = hz / VM_INACT_SCAN_RATE; shortage = 0; target_met = true; @@ -1912,8 +1916,10 @@ */ vm_domain_pageout_unlock(vmd); if (!target_met) - pause("pwait", hz / VM_INACT_SCAN_RATE); + pause("pwait", period - ((u_int)ticks % + period)); } else { +dt = period - ((u_int)ticks % period); /* * No, sleep until the next wakeup or until pages * need to have their reference stats updated. @@ -1920,7 +1926,7 @@ */ if (mtx_sleep(&vmd->vmd_pageout_wanted, vm_domain_pageout_lockptr(vmd), PDROP | PVM, - "psleep", hz / VM_INACT_SCAN_RATE) == 0) + "psleep", period - ((u_int)ticks % period)) == 0) VM_CNT_INC(v_pdwakeups); }