On Tue, Oct 11, 2022, Colton Lewis wrote: > Sean Christopherson <seanjc@xxxxxxxxxx> writes: > > > On Mon, Sep 12, 2022, Colton Lewis wrote: > > > Implement random number generation for guest code to randomize parts > > > of the test, making it less predictable and a more accurate reflection > > > of reality. > > > > Create a -r argument to specify a random seed. If no argument is > > > provided, the seed defaults to 0. The random seed is set with > > > perf_test_set_random_seed() and must be set before guest_code runs to > > > apply. > > > > The random number generator chosen is the Park-Miller Linear > > > Congruential Generator, a fancy name for a basic and well-understood > > > random number generator entirely sufficient for this purpose. Each > > > vCPU calculates its own seed by adding its index to the seed provided. > > > Why not grab the kernel's pseudo-RNG from prandom_seed_state() + > > prandom_u32_state()? > > The guest is effectively a minimal kernel running in a VM that doesn't > have access to this, correct? Oh, I didn't mean link to the kernel code, I meant "why not copy+paste the kernel code?". In other words, why select a different RNG implementation than what the kernel uses? In general, selftests and tools try to follow the kernel code, even when copy+pasting, as that avoids questions like "why does the kernel do X but selftests do Y?". The copy+paste does sometimes lead to maintenance pain, e.g. if the copied code has a bug that the kernel then fixes, but that seems unlikely to happen in this case.