[*] Improve RNG fallback performance (early process init canaries) by properly accounting for < 10 Mhz clocks

This commit is contained in:
Reece Wilson 2023-10-07 14:50:32 +01:00
parent 605862094e
commit 478cb2b185

View File

@ -174,7 +174,11 @@ namespace Aurora::RNG
#if 0
return clock(); // [...] resolution of 1 posix clock() tick (this is usually 1,000,000 == CLOCKS_PER_SEC per posix, but it can be 1k)
#else
return AuTime::SteadyClockNS() / 10'000ull;
static AuUInt64 gTimeHolder;
static AuUInt64 gTime = (gTimeHolder = AuTime::SteadyClockJiffies()) >= 10'000'000ull ?
1 :
(10'000'000ull / AuPageRoundUp<AuUInt64>(gTimeHolder, 1024));
return AuTime::SteadyClockNS() * gTime / 10'000ull;
#endif
}
@ -213,6 +217,7 @@ namespace Aurora::RNG
// ...but still, let's continue.
// Deadlocking preprocess init, because for example the motherboard is failing or a VM configuration changed, is pretty dumb.
// (ask me how i know)
// Update oct: it scales with whatever frequency user-land clocks can be trusted with, per the respective kernels' HAL (viso, kshared user data, etc).
}
while (a == b); // ensure theres enough entropy for a deviation to occur
acc = (acc << 1) | a; // push the first bit state