summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/include/perf_test_util.h
diff options
context:
space:
mode:
authorColton Lewis <coltonlewis@google.com>2022-11-07 18:22:07 +0000
committerSean Christopherson <seanjc@google.com>2022-11-16 10:57:19 -0800
commit6864c6442f4dfa02c7cf48199cf3ea6bb1fe74ed (patch)
tree53f27995f75db67791895886364121aa6480740f /tools/testing/selftests/kvm/include/perf_test_util.h
parentf11aa24bdbc66a10378d28ee962b95426e8d2a09 (diff)
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>
Diffstat (limited to 'tools/testing/selftests/kvm/include/perf_test_util.h')
-rw-r--r--tools/testing/selftests/kvm/include/perf_test_util.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/testing/selftests/kvm/include/perf_test_util.h b/tools/testing/selftests/kvm/include/perf_test_util.h
index 5a0e48b625a2..6470ca0fec4c 100644
--- a/tools/testing/selftests/kvm/include/perf_test_util.h
+++ b/tools/testing/selftests/kvm/include/perf_test_util.h
@@ -36,7 +36,7 @@ struct perf_test_args {
uint64_t size;
uint64_t guest_page_size;
uint32_t random_seed;
- int wr_fract;
+ uint32_t write_percent;
/* Run vCPUs in L2 instead of L1, if the architecture supports it. */
bool nested;
@@ -56,7 +56,7 @@ struct kvm_vm *perf_test_create_vm(enum vm_guest_mode mode, int nr_vcpus,
bool partition_vcpu_memory_access);
void perf_test_destroy_vm(struct kvm_vm *vm);
-void perf_test_set_wr_fract(struct kvm_vm *vm, int wr_fract);
+void perf_test_set_write_percent(struct kvm_vm *vm, uint32_t write_percent);
void perf_test_set_random_seed(struct kvm_vm *vm, uint32_t random_seed);
void perf_test_start_vcpu_threads(int vcpus, void (*vcpu_fn)(struct perf_test_vcpu_args *));