summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/kvm/kvm_page_table_test.c
diff options
context:
space:
mode:
authorBibo Mao <maobibo@loongson.cn>2023-07-31 05:24:05 +0300
committerSean Christopherson <seanjc@google.com>2023-08-02 23:36:08 +0300
commitb859b018aadfd05f0526533fd1bcf04024d01917 (patch)
tree15f7d59a5dda43f79baa273573e93e0e5e38aaec /tools/testing/selftests/kvm/kvm_page_table_test.c
parent0de704d2d6c82c7498fa1b8df66903f8139e3de2 (diff)
downloadlinux-b859b018aadfd05f0526533fd1bcf04024d01917.tar.xz
KVM: selftests: use unified time type for comparison
With test case kvm_page_table_test, start time is acquired with time type CLOCK_MONOTONIC_RAW, however end time in timespec_elapsed() is acquired with time type CLOCK_MONOTONIC. This can cause inaccurate elapsed time calculation due to mixing timebases, e.g. LoongArch in particular will see weirdness. Modify kvm_page_table_test to use unified time type CLOCK_MONOTONIC for start time. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Oliver Upton <oliver.upton@linux.dev> Link: https://lore.kernel.org/r/20230731022405.854884-1-maobibo@loongson.cn [sean: massage changelog] Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/testing/selftests/kvm/kvm_page_table_test.c')
-rw-r--r--tools/testing/selftests/kvm/kvm_page_table_test.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/testing/selftests/kvm/kvm_page_table_test.c b/tools/testing/selftests/kvm/kvm_page_table_test.c
index b3b00be1ef82..69f26d80c821 100644
--- a/tools/testing/selftests/kvm/kvm_page_table_test.c
+++ b/tools/testing/selftests/kvm/kvm_page_table_test.c
@@ -200,7 +200,7 @@ static void *vcpu_worker(void *data)
if (READ_ONCE(host_quit))
return NULL;
- clock_gettime(CLOCK_MONOTONIC_RAW, &start);
+ clock_gettime(CLOCK_MONOTONIC, &start);
ret = _vcpu_run(vcpu);
ts_diff = timespec_elapsed(start);
@@ -367,7 +367,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
/* Test the stage of KVM creating mappings */
*current_stage = KVM_CREATE_MAPPINGS;
- clock_gettime(CLOCK_MONOTONIC_RAW, &start);
+ clock_gettime(CLOCK_MONOTONIC, &start);
vcpus_complete_new_stage(*current_stage);
ts_diff = timespec_elapsed(start);
@@ -380,7 +380,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
*current_stage = KVM_UPDATE_MAPPINGS;
- clock_gettime(CLOCK_MONOTONIC_RAW, &start);
+ clock_gettime(CLOCK_MONOTONIC, &start);
vcpus_complete_new_stage(*current_stage);
ts_diff = timespec_elapsed(start);
@@ -392,7 +392,7 @@ static void run_test(enum vm_guest_mode mode, void *arg)
*current_stage = KVM_ADJUST_MAPPINGS;
- clock_gettime(CLOCK_MONOTONIC_RAW, &start);
+ clock_gettime(CLOCK_MONOTONIC, &start);
vcpus_complete_new_stage(*current_stage);
ts_diff = timespec_elapsed(start);