Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1475336
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 3/4] KVM: x86: introduce get_kvmclock_ns |
| Date | 2016-09-02 18:40 +0200 |
| Message-ID | <scZFw-1Qn-9@gated-at.bofh.it> (permalink) |
| References | <scC6e-3Bv-17@gated-at.bofh.it> <scC6e-3Bv-19@gated-at.bofh.it> <scXu1-wL-11@gated-at.bofh.it> <scXu1-wL-9@gated-at.bofh.it> <scZFw-1Qn-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 02/09/2016 16:51, Roman Kagan wrote: > On Fri, Sep 02, 2016 at 04:09:42PM +0200, Paolo Bonzini wrote: >> On 02/09/2016 15:52, Roman Kagan wrote: >> vs. using a single offset as in the TSC ref page is one nanosecond---and >> the ref page only has a resolution of 100 ns. > > AFAICS it's not a matter of resolution. If one calculation flips from > value T to T+1 at tsc1, while the other at tsc2, during the window > between tsc1 and tsc2 we can have monotonicity violation. Ok, tried "empirically" (throw numbers in a spreadsheet :)) and indeed the maximum error is not 1 ns but 100 ns (1 unit in the time reference count MSR). You can get a flip between T/T+1 because the time reference counter may be more precise with its rounding due to the separation between tsc_timestamp and system_time. This separation provides some extra decimal digits to the offset, which the TSC page lacks. For example: 51256391 tsc_timestamp 3311474323 tsc_to_system_mul 254246 system_time -1 shift -195054.1816 offset (computed exactly) So the flip happens when the nanoseconds are around 81/82: tsc kvmclock refcount TSC page 51256391 254246 2542 2542 51256483 254281 2542 2542 51256484 254281 2542 2543 51256486 254282 2542 2543 51256746 254382 2543 2544 I'll change patch 4 to store the parameters and use them when accessing the time reference counter MSR. I'll still keep the procedure that goes through kvmclock. It's a bit more involved for the scale, but vcpu->last_guest_tsc only provides a part of the offset computation; the other half is vcpu->hv_clock.system_time and it's not stored anywhere. Paolo
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 3/4] KVM: x86: introduce get_kvmclock_ns Paolo Bonzini <pbonzini@redhat.com> - 2016-09-01 17:30 +0200
Re: [PATCH 3/4] KVM: x86: introduce get_kvmclock_ns Paolo Bonzini <pbonzini@redhat.com> - 2016-09-02 16:20 +0200
Re: [PATCH 3/4] KVM: x86: introduce get_kvmclock_ns Paolo Bonzini <pbonzini@redhat.com> - 2016-09-02 18:40 +0200
Re: [PATCH 3/4] KVM: x86: introduce get_kvmclock_ns Paolo Bonzini <pbonzini@redhat.com> - 2016-09-02 19:00 +0200
Re: [PATCH 3/4] KVM: x86: introduce get_kvmclock_ns Paolo Bonzini <pbonzini@redhat.com> - 2016-09-05 16:00 +0200
csiph-web