From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753395AbdARQHP (ORCPT ); Wed, 18 Jan 2017 11:07:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49974 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752801AbdARQHN (ORCPT ); Wed, 18 Jan 2017 11:07:13 -0500 Subject: Re: [patch 3/3] PTP: add kvm PTP driver To: Miroslav Lichvar , Marcelo Tosatti References: <20170116193655.GA7649@amt.cnet> <20170116194715.GA8017@amt.cnet> <20170116200112.GB8739@amt.cnet> <20170117080327.GG14227@localhost> <20170117113052.GA27759@amt.cnet> <20170117153621.GE31452@potion> <20170118121738.GA14832@amt.cnet> <20170118122456.GC13762@amt.cnet> <94a761cb-8bcd-e1a6-d07e-02fedc423e33@redhat.com> <20170118142409.GA9713@amt.cnet> <20170118155452.GM14227@localhost> Cc: Radim Krcmar , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Richard Cochran From: Paolo Bonzini Message-ID: <1168c0c1-fe82-c60f-6a15-9aa890b2b617@redhat.com> Date: Wed, 18 Jan 2017 17:07:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20170118155452.GM14227@localhost> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 18 Jan 2017 16:07:14 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/01/2017 16:54, Miroslav Lichvar wrote: >> Sure, I'll check if it makes sense to implement PTP_SYS_OFFSET_PRECISE for >> KVM case. > But is it really so precise that the application can safely assume > there are no errors due to asymmetric delays, etc? I think > PTP_SYS_OFFSET_PRECISE should be supported only if the accuracy of > the offset measured between the HW and system clock is not worse than > the precision of the system clock (typically few tens of nanoseconds). > > It would be good to verify the accuracy of the offset when the host > and guest clocks are synchronised to each other over PTP using two > NICs with HW timestamping. PTP_SYS_OFFSET_PRECISE works if the guest can compute its own timestamp based on the same source as the device. On bare metal you have: - the source for system clock is the TSC (with clocksource_tsc) - device provides a (time, ART) tuple You can convert ART->TSC and then ask clocksource_tsc for a system time based on the device-provided ART value. Likewise for KVM: - the source for system clock is the guest TSC (with kvmclock) - host can provide a (time, guest TSC) tuple The PTP driver can take the host-provided guest TSC, and ask kvmclock for a system time based on that TSC value. It's even simpler because there's no ART->TSC conversion involved, and it will always be precise and independent of any vmexit or interrupt delay. Paolo