Skip to content

Commit 8f22643

Browse files
committed
hmm
1 parent 3a6bb82 commit 8f22643

5 files changed

Lines changed: 46 additions & 21 deletions

File tree

boot/bootdata/livecd.inf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ HKLM,"SYSTEM\CurrentControlSet\Services\Cdrom","Start",0x00010001,0x00000000
2727
; KDB. Off for the automated benchmark image.
2828
HKLM,"SYSTEM\CurrentControlSet\Services\i8042prt\Parameters","CrashOnCtrlScroll",0x00010001,0x00000000
2929

30+
; Disable the i8042 (PS/2) driver entirely (Start = SERVICE_DISABLED = 4). This q35
31+
; board has an i8042 controller with NO PS/2 keyboard/mouse attached (input is via
32+
; USB-HID), so the controller emits spurious interrupts/scancodes that intermittently
33+
; crash i8042prt during init (e.g. ASSERT ControlPort!=NULL in i8042ReadStatus, or the
34+
; SYSRQ break) -- a major source of flaky SMP boot. The USB keyboard is unaffected.
35+
HKLM,"SYSTEM\CurrentControlSet\Services\i8042prt","Start",0x00010001,0x00000004
36+
HKLM,"SYSTEM\CurrentControlSet\Services\i8042prt","DependOnService",0x00010000,""
37+
3038
; Reset BootExecute to an empty value: AutoChk should not start in MiniNT mode
3139
HKLM,"SYSTEM\CurrentControlSet\Control\Session Manager","BootExecute",0x00010000,""
3240

drivers/input/i8042prt/registry.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* PROGRAMMERS: Copyright Victor Kirhenshtein (sauros@iname.com)
77
Copyright Jason Filby (jasonfilby@yahoo.com)
88
Copyright Martijn Vernooij (o112w8r02@sneakemail.com)
9-
Copyright 2006-2007 Hervé Poussineau (hpoussin@reactos.org)
9+
Copyright 2006-2007 Herv� Poussineau (hpoussin@reactos.org)
1010
*/
1111

1212
/* INCLUDES ******************************************************************/
@@ -41,14 +41,13 @@ ReadRegistryEntries(
4141
ULONG DefaultSampleRate = 60;
4242
ULONG DefaultCrashOnCtrlScroll;
4343

44-
/* Default value for CrashOnCtrlScroll depends if we're
45-
* running a debug build or a normal build.
46-
*/
47-
#if DBG
48-
DefaultCrashOnCtrlScroll = 1;
49-
#else
44+
/* Default value for CrashOnCtrlScroll. Normally ON in debug builds, but on
45+
* this branch the q35 board has an i8042 controller with no PS/2 keyboard
46+
* attached (we use USB), so it feeds spurious scancodes that intermittently
47+
* match the TAB+k / Ctrl+ScrollLock debug-break sequence and drop an
48+
* unattended boot into KDB. Default it OFF so a stray byte can't crash boot;
49+
* the registry value (livecd.inf) can still override. */
5050
DefaultCrashOnCtrlScroll = 0;
51-
#endif
5251

5352
RtlZeroMemory(Parameters, sizeof(Parameters));
5453

hal/halx86/apic/rtctimer.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121

2222
static const UCHAR RtcMinimumClockRate = 6; /* Minimum rate 6: 1024 Hz / 0.97 ms */
2323
static 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;
3840
static ULONG HalpRunningFraction;
3941
static BOOLEAN HalpSetClockRate;
4042
static 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);

ntoskrnl/ke/amd64/stubs.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ KiIdleLoop(VOID)
133133

134134
#ifdef CONFIG_SMP
135135
/* Nothing scheduled for us? Pull a ready thread off a busier CPU rather
136-
* than halting while runnable work sits elsewhere. This provides the
137-
* load-balancing ReactOS otherwise lacks (placement happens once, at
138-
* thread-ready time, with no later migration). */
136+
* than halting while runnable work sits elsewhere (load-balancing). */
139137
if (!Prcb->NextThread)
140138
{
141139
KiStealReadyThread(Prcb);

ntoskrnl/ke/time.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,21 @@ KeUpdateSystemTime(IN PKTRAP_FRAME TrapFrame,
8282
/* Update the tick offset */
8383
OldTickOffset = InterlockedExchangeAdd(&KiTickOffset, -(LONG)Increment);
8484

85-
/* If the debugger is enabled, check for break-in request */
86-
if (KdDebuggerEnabled && KdPollBreakIn())
87-
{
88-
/* Break-in requested! */
89-
DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C);
90-
}
91-
9285
/* Check for full tick */
9386
if (OldTickOffset <= (LONG)Increment)
9487
{
88+
/* If the debugger is enabled, check for break-in request. This is done
89+
* only once per logical tick (~64Hz), NOT on every fine-grained clock
90+
* interrupt: at 1024Hz, polling the debug port 16x more often
91+
* intermittently misreads a spurious break-in over the serial line and
92+
* drops to KDB ("embedded INT3" via DbgBreakPointWithStatus), which was
93+
* the most common SMP-boot crash after the timer rate was raised. */
94+
if (KdDebuggerEnabled && KdPollBreakIn())
95+
{
96+
/* Break-in requested! */
97+
DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C);
98+
}
99+
95100
/* Update the system time */
96101
CurrentTime.QuadPart = *(ULONGLONG*)&SharedUserData->SystemTime;
97102
CurrentTime.QuadPart += KeTimeAdjustment;

0 commit comments

Comments
 (0)