KVM: selftests: Make hyperv_clock selftest more stable
authorVitaly Kuznetsov <vkuznets@redhat.com>
Wed, 1 Jun 2022 14:43:22 +0000 (16:43 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 7 Jun 2022 15:28:50 +0000 (11:28 -0400)
commiteae260be3a0111a28fe95923e117a55dddec0384
tree3e529bd5b529778bca2cffb7b0b7e6f8b07eccac
parent5ba7c4c6d1c7af47a916f728bb5940669684a087
KVM: selftests: Make hyperv_clock selftest more stable

hyperv_clock doesn't always give a stable test result, especially with
AMD CPUs. The test compares Hyper-V MSR clocksource (acquired either
with rdmsr() from within the guest or KVM_GET_MSRS from the host)
against rdtsc(). To increase the accuracy, increase the measured delay
(done with nop loop) by two orders of magnitude and take the mean rdtsc()
value before and after rdmsr()/KVM_GET_MSRS.

Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Tested-by: Maxim Levitsky <mlevitsk@redhat.com>
Message-Id: <20220601144322.1968742-1-vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/x86_64/hyperv_clock.c