From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Maxim Levitsky <mlevitsk@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: FYI: hyperv_clock selftest has random failures
Date: Wed, 25 May 2022 16:59:34 +0200 [thread overview]
Message-ID: <87zgj5r73d.fsf@redhat.com> (raw)
In-Reply-To: <201c43722d7f0faffc9a2377fd25fd31f4565898.camel@redhat.com>
Maxim Levitsky <mlevitsk@redhat.com> writes:
> Just something I noticed today. Happens on both AMD and Intel, kvm/queue.
>
> Likely the test needs lower tolerancies.
>
> I'll investigate this later
>
> This is on my AMD machine (3970X):
>
> [mlevitsk@starship ~/Kernel/master/src/tools/testing/selftests/kvm]$while true ; do ./x86_64/hyperv_clock ; done
> ==== Test Assertion Failure ====
> x86_64/hyperv_clock.c:199: delta_ns * 100 < (t2 - t1) * 100
> pid=66218 tid=66218 errno=0 - Success
> 1 0x000000000040255d: host_check_tsc_msr_rdtsc at hyperv_clock.c:199
> 2 (inlined by) main at hyperv_clock.c:223
> 3 0x00007f0f2822d55f: ?? ??:0
> 4 0x00007f0f2822d60b: ?? ??:0
> 5 0x0000000000402744: _start at ??:?
> Elapsed time does not match (MSR=471600, TSC=461024)
...
Here the test is:
r1 = rdtsc()
m1 = KVM_GET_MSRS (HV_X64_MSR_TIME_REF_COUNT)
nop_loop()
r2 = rdtsc()
m2 = KVM_GET_MSRS (HV_X64_MSR_TIME_REF_COUNT)
and then we compare the difference between rdtsc()-s and
HV_X64_MSR_TIME_REF_COUNT changes with 1% tolerance (r2-r1 vs m2-m1).
It would probably increase accuracy if we do
r1_1 = rdtsc()
KVM_GET_MSRS (HV_X64_MSR_TIME_REF_COUNT)
r1_2 = rdtsc()
nop_loop()
r2_1 = rdtsc()
KVM_GET_MSRS (HV_X64_MSR_TIME_REF_COUNT)
r2_2 = rdtsc()
and compare (r2_2 + r2_1)/2 - (r2_1 + r2_2)/2 vs m2-m1.
and also increase tolerance to say 5%.
> ==== Test Assertion Failure ====
> x86_64/hyperv_clock.c:234: false
> pid=66652 tid=66652 errno=4 - Interrupted system call
> 1 0x00000000004026e7: main at hyperv_clock.c:234
> 2 0x00007fdab782d55f: ?? ??:0
> 3 0x00007fdab782d60b: ?? ??:0
> 4 0x0000000000402744: _start at ??:?
> Failed guest assert: delta_ns * 100 < (t2 - t1) * 100 at x86_64/hyperv_clock.c:74
Same story as above but from within the guest (rdmsr() istead of
KVM_GET_MSRS). We can probably employ the same idea to increate the
accuracy.
--
Vitaly
prev parent reply other threads:[~2022-05-25 15:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-25 14:35 FYI: hyperv_clock selftest has random failures Maxim Levitsky
2022-05-25 14:59 ` Vitaly Kuznetsov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zgj5r73d.fsf@redhat.com \
--to=vkuznets@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox