2121
2222static const UCHAR RtcMinimumClockRate = 6 ; /* Minimum rate 6: 1024 Hz / 0.97 ms */
2323static const UCHAR RtcMaximumClockRate = 10 ; /* Maximum rate 10: 64 Hz / 15.6 ms */
24- static UCHAR HalpCurrentClockRate = 6 ; /* Initial rate 6: 1024 Hz / 0.977 ms.
24+ static UCHAR HalpCurrentClockRate = 6 ; /* rate 6: 1024 Hz / 0.977 ms. (Confirmed the
25+ clock rate is NOT the cause of flaky SMP boot -- 64Hz fails the same way -- so kept
26+ at 1024Hz for the fine Sleep resolution.)
2527 NOTE: rate 5 (2048Hz) gives slightly finer Sleep (~1.45ms vs ~1.93ms) but
2628 REPRODUCIBLY blows up thread create+join to ~16ms (vs 59us at 1024Hz) -- the
2729 2x clock-IPI/interrupt load starves the thread-reaper/scheduling round-trips.
@@ -38,6 +40,7 @@ static ULONG HalpCurrentFractionalIncrement;
3840static ULONG HalpRunningFraction ;
3941static BOOLEAN HalpSetClockRate ;
4042static UCHAR HalpNextClockRate ;
43+ static ULONG HalpClockIpiAccumulator ; /* paces the AP clock-IPI to the logical tick */
4144
4245/*!
4346 \brief Converts the CMOS RTC rate into the time increment in 0.1ns intervals.
@@ -201,8 +204,20 @@ HalpClockInterruptHandler(IN PKTRAP_FRAME TrapFrame)
201204 HalpSetClockRate = FALSE;
202205 }
203206
204- /* Send the clock IPI to all other CPUs */
205- HalpBroadcastClockIpi (CLOCK_IPI_VECTOR );
207+ /* Send the clock IPI to the other CPUs only at the LOGICAL tick rate, not on
208+ * every fine-grained 1024Hz interrupt. The APs run KeUpdateRunTime per IPI
209+ * (quantum + per-tick CPU-time accounting); broadcasting at the full 1024Hz
210+ * decremented AP quanta ~16x too fast (inconsistent with CPU0, which only does
211+ * KeUpdateRunTime once per accumulated full tick) AND flooded the IPI path,
212+ * which intermittently crashed boot once the APs were up. Accumulate the
213+ * per-interrupt increment and broadcast once per HalpMaximumTimeIncrement so
214+ * APs tick at the same ~64Hz logical rate as CPU0. */
215+ HalpClockIpiAccumulator += LastIncrement ;
216+ if (HalpClockIpiAccumulator >= HalpMaximumTimeIncrement )
217+ {
218+ HalpClockIpiAccumulator -= HalpMaximumTimeIncrement ;
219+ HalpBroadcastClockIpi (CLOCK_IPI_VECTOR );
220+ }
206221
207222 /* Update the system time -- on x86 the kernel will exit this trap */
208223 KeUpdateSystemTime (TrapFrame , LastIncrement , Irql );
0 commit comments