Re: [PATCH v6 1/3] KVM: selftests: implement random number generation for guest code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sean Christopherson <seanjc@xxxxxxxxxx> writes:

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.

The real answer is I didn't know about it at the time. But I do think
the prandom_32_state seems like overkill for this application.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux