Re: [PATCH v5 3/3] KVM: selftests: randomize page access order

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

 



David Matlack <dmatlack@xxxxxxxxxx> writes:

On Fri, Sep 9, 2022 at 10:31 AM Ricardo Koller <ricarkol@xxxxxxxxxx> wrote:

On Fri, Sep 09, 2022 at 10:26:10AM -0700, David Matlack wrote:
> On Fri, Sep 09, 2022 at 12:43:00PM +0000, Colton Lewis wrote:
> > Create the ability to randomize page access order with the -a
> > argument, including the possibility that the same pages may be hit
> > multiple times during an iteration or not at all.
> >
> > Population sets random access to false.
>
> Please make sure to also explain the why in addition to the what.
>

Will do.

> > @@ -57,7 +58,13 @@ void perf_test_guest_code(uint32_t vcpu_id)
> >
> >     while (true) {
> >             for (i = 0; i < pages; i++) {
> > -                   uint64_t addr = gva + (i * pta->guest_page_size);
> > +                   guest_random(&rand);
> > +
> > +                   if (pta->random_access)
> > + addr = gva + ((rand % pages) * pta->guest_page_size);
> > +                   else
> > +                           addr = gva + (i * pta->guest_page_size);
> > +
> >                     guest_random(&rand);
>
> Is it on purpose use a separate random number for access offset and
> read/write?
>

It's because of the following, from https://lore.kernel.org/kvm/YxDvVyFpMC9U3O25@xxxxxxxxxx/

         I think addr and write_percent need two different random numbers.
Otherwise, you will end up with a situation where all addresses where (rnd_arr[i] % 100 < pta->write_percent) will get a write (always).
         Something like this:

                 012345678    <= address
                 wwwrrrwww
                 837561249    <= access order

         I think the best way to fix this is to abstract the random number
         reading into something like get_next_rand(), and use it twice per
         iteration.

Makes sense. Depending on how many bits of randomness we need (e.g.
read/write only needs 7) we could still use one random number. But the
bit manipulation would probably more complex than just generating
another random number (which looks like a fairly cheap calculation).

Colton can you add a comment here to explain the subtlety?


Will do.



[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