Initialize 'ticks' earlier in boot after 'hz' is set.

This avoids the time-warp after kthreads have started running and the
required fixup to td_slptick and td_blktick in the EARLY_AP_STARTUP
case.  Now, 'ticks' is initialized before any kthreads are created or
any context switches are performed.

Tested by:	gavin
MFC after:	2 weeks
Sponsored by:	Netflix
This commit is contained in:
John Baldwin 2016-11-22 01:02:59 +00:00
parent 1279fdafce
commit 5d8cce1764
2 changed files with 6 additions and 38 deletions

View File

@ -393,10 +393,6 @@ static void
initclocks(dummy)
void *dummy;
{
#ifdef EARLY_AP_STARTUP
struct proc *p;
struct thread *td;
#endif
register int i;
/*
@ -415,40 +411,6 @@ initclocks(dummy)
psratio = profhz / i;
#ifdef SW_WATCHDOG
EVENTHANDLER_REGISTER(watchdog_list, watchdog_config, NULL, 0);
#endif
/*
* Arrange for ticks to wrap 10 minutes after boot to help catch
* sign problems sooner.
*/
ticks = INT_MAX - (hz * 10 * 60);
#ifdef EARLY_AP_STARTUP
/*
* Fixup the tick counts in any blocked or sleeping threads to
* account for the jump above.
*/
sx_slock(&allproc_lock);
FOREACH_PROC_IN_SYSTEM(p) {
PROC_LOCK(p);
if (p->p_state == PRS_NEW) {
PROC_UNLOCK(p);
continue;
}
FOREACH_THREAD_IN_PROC(p, td) {
thread_lock(td);
if (TD_ON_LOCK(td)) {
MPASS(td->td_blktick == 0);
td->td_blktick = ticks;
}
if (TD_ON_SLEEPQ(td)) {
MPASS(td->td_slptick == 0);
td->td_slptick = ticks;
}
thread_unlock(td);
}
PROC_UNLOCK(p);
}
sx_sunlock(&allproc_lock);
#endif
}

View File

@ -171,6 +171,12 @@ init_param1(void)
tick_sbt = SBT_1S / hz;
tick_bt = sbttobt(tick_sbt);
/*
* Arrange for ticks to wrap 10 minutes after boot to help catch
* sign problems sooner.
*/
ticks = INT_MAX - (hz * 10 * 60);
#ifdef VM_SWZONE_SIZE_MAX
maxswzone = VM_SWZONE_SIZE_MAX;
#endif