mirror of
https://github.com/reactos/reactos.git
synced 2024-11-23 19:43:31 +08:00
[NTOS:KE] Don't loop indefinitely trying to figure out the CPU frequency. CORE-14419
Previously, we would keep sampling the CPU frequency until two subsequent samples differed by at most 1 MHz. This could take several seconds, and would unnecessarily delay boot. Instead, if sampling is too unreliable, just give up and calculate the average frequency from 10 samples. This is no worse than picking the frequency that just happened to be returned twice in a row. The fact that this method of sampling fails could indicate that there's a problem with our performance counter implementation or timer interrupt, but that's a separate issue...
This commit is contained in:
parent
d214e1c4d4
commit
6b78ff036f
@ -44,7 +44,7 @@ KiInitMachineDependent(VOID)
|
||||
PFX_SAVE_AREA FxSaveArea;
|
||||
ULONG MXCsrMask = 0xFFBF;
|
||||
CPU_INFO CpuInfo;
|
||||
KI_SAMPLE_MAP Samples[4];
|
||||
KI_SAMPLE_MAP Samples[10];
|
||||
PKI_SAMPLE_MAP CurrentSample = Samples;
|
||||
LARGE_IDENTITY_MAP IdentityMap;
|
||||
|
||||
@ -240,11 +240,17 @@ KiInitMachineDependent(VOID)
|
||||
CurrentSample++;
|
||||
Sample++;
|
||||
|
||||
if (Sample == sizeof(Samples) / sizeof(Samples[0]))
|
||||
if (Sample == RTL_NUMBER_OF(Samples))
|
||||
{
|
||||
/* Restart */
|
||||
CurrentSample = Samples;
|
||||
Sample = 0;
|
||||
/* No luck. Average the samples and be done */
|
||||
ULONG TotalMHz = 0;
|
||||
while (Sample--)
|
||||
{
|
||||
TotalMHz += Samples[Sample].MHz;
|
||||
}
|
||||
CurrentSample[-1].MHz = TotalMHz / RTL_NUMBER_OF(Samples);
|
||||
DPRINT1("Sampling CPU frequency failed. Using average of %lu MHz\n", CurrentSample[-1].MHz);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user