Index: sys/arm64/arm64/mp_machdep.c =================================================================== --- sys/arm64/arm64/mp_machdep.c +++ sys/arm64/arm64/mp_machdep.c @@ -266,9 +266,6 @@ intr_pic_init_secondary(); - /* Start per-CPU event timers. */ - cpu_initclocks_ap(); - #ifdef VFP vfp_init(); #endif @@ -301,9 +298,11 @@ static void smp_after_idle_runnable(void *arg __unused) { + struct thread *td; struct pcpu *pc; int cpu; + td = curthread; for (cpu = 1; cpu < mp_ncpus; cpu++) { if (bootstacks[cpu] != NULL) { pc = pcpu_find(cpu); @@ -311,7 +310,22 @@ cpu_spinwait(); kmem_free((vm_offset_t)bootstacks[cpu], PAGE_SIZE); } + + /* + * Start any CPU-specific event timers. This is done relatively + * late to avoid processing callouts before the transition to + * idlethread has put us in the proper scheduler state. + */ + thread_lock(td); + sched_bind(td, cpu); + thread_unlock(td); + cpu_initclocks_ap(); } + + thread_lock(td); + if (sched_is_bound(td)) + sched_unbind(td); + thread_unlock(td); } SYSINIT(smp_after_idle_runnable, SI_SUB_SMP, SI_ORDER_ANY, smp_after_idle_runnable, NULL);