Skip to content

Commit

Permalink
KVM: selftests: Report per-vcpu demand paging rate from demand paging…
Browse files Browse the repository at this point in the history
… test

Using the overall demand paging rate to measure performance can be
slightly misleading when vCPU accesses are not overlapped. Adding more
vCPUs will (usually) increase the overall demand paging rate even
if performance remains constant or even degrades on a per-vcpu basis. As
such, it makes sense to report both the total and per-vcpu paging rates.

Signed-off-by: Anish Moorthy <amoorthy@google.com>
Link: https://lore.kernel.org/r/20240215235405.368539-11-amoorthy@google.com
[sean: fix formatting]
Signed-off-by: Sean Christopherson <seanjc@google.com>
  • Loading branch information
anlsh authored and sean-jc committed Apr 9, 2024
1 parent fec50db commit 2ca76c1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tools/testing/selftests/kvm/demand_paging_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
struct uffd_desc **uffd_descs = NULL;
struct timespec start;
struct timespec ts_diff;
double vcpu_paging_rate;
struct kvm_vm *vm;
int i;

Expand Down Expand Up @@ -191,11 +192,15 @@ static void run_test(enum vm_guest_mode mode, void *arg)
uffd_stop_demand_paging(uffd_descs[i]);
}

pr_info("Total guest execution time: %ld.%.9lds\n",
pr_info("Total guest execution time:\t%ld.%.9lds\n",
ts_diff.tv_sec, ts_diff.tv_nsec);
pr_info("Overall demand paging rate: %f pgs/sec\n",
memstress_args.vcpu_args[0].pages * nr_vcpus /
((double)ts_diff.tv_sec + (double)ts_diff.tv_nsec / NSEC_PER_SEC));

vcpu_paging_rate = memstress_args.vcpu_args[0].pages /
((double)ts_diff.tv_sec + (double)ts_diff.tv_nsec / NSEC_PER_SEC);
pr_info("Per-vcpu demand paging rate:\t%f pgs/sec/vcpu\n",
vcpu_paging_rate);
pr_info("Overall demand paging rate:\t%f pgs/sec\n",
vcpu_paging_rate * nr_vcpus);

memstress_destroy_vm(vm);

Expand Down

0 comments on commit 2ca76c1

Please sign in to comment.