Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1560723
| From | Radim Krcmar <rkrcmar@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [patch 3/3] PTP: add kvm PTP driver |
| Date | 2017-01-17 16:40 +0100 |
| Message-ID | <t0E1A-mt-29@gated-at.bofh.it> (permalink) |
| References | (5 earlier) <t0lih-54V-7@gated-at.bofh.it> <t0lrX-58K-17@gated-at.bofh.it> <t0lLk-5zl-19@gated-at.bofh.it> <t0x06-4x1-13@gated-at.bofh.it> <t0Ahj-6wt-15@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
2017-01-17 09:30-0200, Marcelo Tosatti:
> On Tue, Jan 17, 2017 at 09:03:27AM +0100, Miroslav Lichvar wrote:
>> On Mon, Jan 16, 2017 at 06:01:14PM -0200, Marcelo Tosatti wrote:
>> > On Mon, Jan 16, 2017 at 05:47:15PM -0200, Marcelo Tosatti wrote:
>> > > On Mon, Jan 16, 2017 at 05:36:55PM -0200, Marcelo Tosatti wrote:
>> > > > Sorry, unless i am misunderstanding how this works, it'll get the guest clock
>> > > > 2us behind, which is something not wanted.
>> > > >
>> > > > Miroslav, if ->gettime64 returns the host realtime at 2us in the past,
>> > > > this means Chrony will sync the guest clock to
>> > > >
>> > > > host realtime - 2us
>> > > >
>> > > > Is that correct?
>>
>> Probably. It depends on the error of both host and guest timestamps.
>> If the error is the same on both sides, it will cancel out. An
>> occasional spike in the delay shouldn't be a problem as the reading
>> will be filtered out, but for best accuracy it's necessary that the
>> host's timestamp is taken in the middle between the guest's
>> timestamps.
>
> The problem is that spikes can be far from occasional: it depends on activity of
> the host CPU and interrupts. Whose delay can be "intermittent": as long
> as interrupts are being sent to the host CPU, for example, the delay
> will be high (which can last minutes).
>
> The TSC reading in the guest KVM PTP driver corrects for that delay.
>
>> Users of the PTP_SYS_OFFSET ioctl assume that (ts[0]+ts[2])/2
>> corresponds to ts[1], (ts[2]+ts[4])/2 corresponds to ts[3], and so on.
>>
>> ts[1] ts[3]
>> Host time ---------+---------+........
>> | |
>> | |
>> Guest time ----+---------+---------+......
>> ts[0] ts[2] ts[4]
KVM PTP delay moves host ts[i] to be close to guest ts[i+1] and makes
the offset very consistent, so the graph would look like:
ts[1] ts[3]
Host time -------------+---------+........
| |
| |
Guest time ----+---------+---------+......
ts[0] ts[2] ts[4]
which doesn't sound good if users assume that the host reading is in the
middle -- the guest time would be ahead of the host time.
I'm wondering why is the PTP precision around 10ns, when the hypercall
takes around 2-3k cycles. Have you measured the guest<->host offset by
getting the output of the hypercall, i.e.
{host_sec @ tsc, host_nsec @ tsc, tsc}
and comparing it with guest time computed from the same tsc, i.e.
{guest_sec @ tsc, guest_nsec @ tsc}
?
Thanks.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [patch 3/3] PTP: add kvm PTP driver Marcelo Tosatti <mtosatti@redhat.com> - 2017-01-16 20:40 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Marcelo Tosatti <mtosatti@redhat.com> - 2017-01-16 20:50 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Marcelo Tosatti <mtosatti@redhat.com> - 2017-01-16 21:10 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Miroslav Lichvar <mlichvar@redhat.com> - 2017-01-17 09:10 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Marcelo Tosatti <mtosatti@redhat.com> - 2017-01-17 12:40 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Radim Krcmar <rkrcmar@redhat.com> - 2017-01-17 16:40 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Marcelo Tosatti <mtosatti@redhat.com> - 2017-01-18 13:20 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Marcelo Tosatti <mtosatti@redhat.com> - 2017-01-18 13:30 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Paolo Bonzini <pbonzini@redhat.com> - 2017-01-18 13:50 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Miroslav Lichvar <mlichvar@redhat.com> - 2017-01-18 14:40 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Paolo Bonzini <pbonzini@redhat.com> - 2017-01-18 15:20 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Marcelo Tosatti <mtosatti@redhat.com> - 2017-01-18 16:00 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Radim Krcmar <rkrcmar@redhat.com> - 2017-01-18 16:40 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Paolo Bonzini <pbonzini@redhat.com> - 2017-01-18 17:00 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Marcelo Tosatti <mtosatti@redhat.com> - 2017-01-20 11:40 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Marcelo Tosatti <mtosatti@redhat.com> - 2017-01-18 15:40 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Miroslav Lichvar <mlichvar@redhat.com> - 2017-01-18 17:00 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Paolo Bonzini <pbonzini@redhat.com> - 2017-01-18 17:10 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Radim Krcmar <rkrcmar@redhat.com> - 2017-01-18 17:20 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Marcelo Tosatti <mtosatti@redhat.com> - 2017-01-18 15:40 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Marcelo Tosatti <mtosatti@redhat.com> - 2017-01-18 16:00 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Radim Krcmar <rkrcmar@redhat.com> - 2017-01-18 16:30 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Marcelo Tosatti <mtosatti@redhat.com> - 2017-01-20 11:40 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Radim Krcmar <rkrcmar@redhat.com> - 2017-01-20 15:30 +0100
Re: [patch 3/3] PTP: add kvm PTP driver Radim Krcmar <rkrcmar@redhat.com> - 2017-01-18 17:10 +0100
csiph-web