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?
If you meant for the seed default. David Matlack specifically insisted
on using the same default every time. And a selftest is a userspace
program that I don't think has access to this either.