From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750845AbdAXLXz (ORCPT ); Tue, 24 Jan 2017 06:23:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59774 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750704AbdAXLXx (ORCPT ); Tue, 24 Jan 2017 06:23:53 -0500 Date: Tue, 24 Jan 2017 09:23:29 -0200 From: Marcelo Tosatti To: Paolo Bonzini Cc: Richard Cochran , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Radim Krcmar , Miroslav Lichvar Subject: Re: [patch 4/5] PTP: add PTP_SYS_OFFSET emulation via cross timestamps infrastructure Message-ID: <20170124112326.GA30511@amt.cnet> References: <20170120122025.665985919@redhat.com> <20170120122503.746158230@redhat.com> <20170120202502.GA10368@localhost.localdomain> <20170123131913.GA28104@amt.cnet> <20170123184415.GA2158@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 24 Jan 2017 11:23:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 23, 2017 at 08:44:53PM +0100, Paolo Bonzini wrote: > > > On 23/01/2017 19:44, Richard Cochran wrote: > >> device clock |sample1P,deviceclock| |sample2P,deviceclock| > >> ------------------------------------------------------------- > >> realtime clock |sample1P,realtimeclock| |sample2P,realtimeclock| > > > > Are |sample1P,deviceclock| and |sample1P,realtimeclock| taken at the > > same instant in time? > > > > If not, then calling that PTP_SYS_OFFSET_PRECISE is misleading. > > Yes, of course. This was added for the e1000e drivers first, but chrony > isn't using it yet. In the case of KVM, the same host TSC value is used > to produce the host clock and (converted to guest TSC) the guest clock. > > If you just implement getclock64 the PTP_SYS_OFFSET output: > > device clock | |sample2| |sample4| |sample6| ... > ------------------------------------------------------------- > realtime clock |sample1| |sample3| |sample5| > > has a very large distance between samples on the same line (about 1 us), > and I think it is too noisy for userspace to make sense of the output. > > So, on one hand chrony only uses the mean of realtime clock samples, in > an attempt to produce precise cross timestamps. On the other hand, even > though KVM could produce those natively, chrony does not support > PTP_SYS_OFFSET_PRECISE. > > Marcelo's patch then produces fake realtime clock samples that, however, > let chrony derive the cross timestamps that KVM produced in the first > place. The outcome is really great accuracy compared to previous > versions of the patch, often just +/- 2 or 3 nanoseconds. > > Paolo Nope, the clock offset is the value inside square brackets. The +/- is the error. So the clock offset is actually up to 680ns. Yes for greater accuracy userspace should implement _PRECISE support. I'm resending v5 with native support for ->gettime and ->getcrosststamps.