KVM: selftests: randomize which pages are written vs read
authorColton Lewis <coltonlewis@google.com>
Mon, 7 Nov 2022 18:22:07 +0000 (18:22 +0000)
committerSean Christopherson <seanjc@google.com>
Wed, 16 Nov 2022 18:57:19 +0000 (10:57 -0800)
commit6864c6442f4dfa02c7cf48199cf3ea6bb1fe74ed
tree53f27995f75db67791895886364121aa6480740f
parentf11aa24bdbc66a10378d28ee962b95426e8d2a09
KVM: selftests: randomize which pages are written vs read

Randomize which pages are written vs read using the random number
generator.

Change the variable wr_fract and associated function calls to
write_percent that now operates as a percentage from 0 to 100 where X
means each page has an X% chance of being written. Change the -f
argument to -w to reflect the new variable semantics. Keep the same
default of 100% writes.

Population always uses 100% writes to ensure all memory is actually
populated and not just mapped to the zero page. The prevents expensive
copy-on-write faults from occurring during the dirty memory iterations
below, which would pollute the performance results.

Each vCPU calculates its own random seed by adding its index to the
seed provided.

Signed-off-by: Colton Lewis <coltonlewis@google.com>
Reviewed-by: David Matlack <dmatlack@google.com>
Link: https://lore.kernel.org/r/20221107182208.479157-4-coltonlewis@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/access_tracking_perf_test.c
tools/testing/selftests/kvm/dirty_log_perf_test.c
tools/testing/selftests/kvm/include/perf_test_util.h
tools/testing/selftests/kvm/lib/perf_test_util.c