Skip to content

Commit 92ab4b9

Browse files
Ben Gardonbonzini
authored andcommitted
KVM: selftests: Add wrfract to common guest code
Wrfract will be used by the dirty logging perf test introduced later in this series to dirty memory sparsely. This series was tested by running the following invocations on an Intel Skylake machine: dirty_log_perf_test -b 20m -i 100 -v 64 dirty_log_perf_test -b 20g -i 5 -v 4 dirty_log_perf_test -b 4g -i 5 -v 32 demand_paging_test -b 20m -v 64 demand_paging_test -b 20g -v 4 demand_paging_test -b 4g -v 32 All behaved as expected. Signed-off-by: Ben Gardon <bgardon@google.com> Message-Id: <20201027233733.1484855-5-bgardon@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 1eafbd2 commit 92ab4b9

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

tools/testing/selftests/kvm/demand_paging_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ static void run_test(enum vm_guest_mode mode, bool use_uffd,
266266

267267
vm = create_vm(mode, vcpus, vcpu_memory_bytes);
268268

269+
perf_test_args.wr_fract = 1;
270+
269271
guest_data_prototype = malloc(perf_test_args.host_page_size);
270272
TEST_ASSERT(guest_data_prototype,
271273
"Failed to allocate buffer for guest data pattern");

tools/testing/selftests/kvm/include/perf_test_util.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct perf_test_args {
4646
struct kvm_vm *vm;
4747
uint64_t host_page_size;
4848
uint64_t guest_page_size;
49+
int wr_fract;
4950

5051
struct vcpu_args vcpu_args[MAX_VCPUS];
5152
};
@@ -72,7 +73,10 @@ static void guest_code(uint32_t vcpu_id)
7273
for (i = 0; i < pages; i++) {
7374
uint64_t addr = gva + (i * perf_test_args.guest_page_size);
7475

75-
*(uint64_t *)addr = 0x0123456789ABCDEF;
76+
if (i % perf_test_args.wr_fract == 0)
77+
*(uint64_t *)addr = 0x0123456789ABCDEF;
78+
else
79+
READ_ONCE(*(uint64_t *)addr);
7680
}
7781

7882
GUEST_SYNC(1);

0 commit comments

Comments
 (0)