@@ -50,6 +50,8 @@ void memstress_guest_code(uint32_t vcpu_idx)
struct memstress_args *args = &memstress_args;
struct memstress_vcpu_args *vcpu_args = &args->vcpu_args[vcpu_idx];
struct guest_random_state rand_state;
+ uint64_t write_access;
+ uint64_t read_access;
uint64_t gva;
uint64_t pages;
uint64_t addr;
@@ -65,6 +67,8 @@ void memstress_guest_code(uint32_t vcpu_idx)
GUEST_ASSERT(vcpu_args->vcpu_idx == vcpu_idx);
while (true) {
+ write_access = 0;
+ read_access = 0;
for (i = 0; i < pages; i++) {
if (args->random_access)
page = guest_random_u32(&rand_state) % pages;
@@ -73,13 +77,16 @@ void memstress_guest_code(uint32_t vcpu_idx)
addr = gva + (page * args->guest_page_size);
- if (guest_random_u32(&rand_state) % 100 < args->write_percent)
+ if (guest_random_u32(&rand_state) % 100 < args->write_percent) {
*(uint64_t *)addr = 0x0123456789ABCDEF;
- else
+ write_access++;
+ } else {
READ_ONCE(*(uint64_t *)addr);
+ read_access++;
+ }
}
- GUEST_SYNC(1);
+ GUEST_SYNC_ARGS(1, read_access, write_access, 0, 0);
}
}
Pass number of read and write accesses done in the memstress' guest code to userspace. These counts will be one way to measure vCPU performances during memstress and dirty logging related tests. For example, in dirty_log_perf_test this can be used to measure impact of dirty and clear log APIs on vCPUs performances. In current dirty_log_perf_test, each vCPU executes in lockstep to the current iteration in userspace, therefore, these access counts will not provide much useful information except for observing individual vCPUs read vs write accesses. However, in future commits, dirty_log_perf_test behavior will be changed to allow vCPUs to execute independent of userspace iterations. This will mimic real world workload where guest keeps on executing while VMM is collecting and clearing dirty logs separately. With read and write accesses known for each vCPU, impact of get and clear dirty log APIs can be quantified. Note that these access counts will not be 100% reliable in knowing vCPUs performances since vCPUs scheduling can impact the progress. Signed-off-by: Vipin Sharma <vipinsh@google.com> --- tools/testing/selftests/kvm/lib/memstress.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)