Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp61081imm; Tue, 9 Oct 2018 13:50:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV62KXe0CiGt8Uh4UuzqyxWvFLBGbFrYDfjP8sRqjs9RCw+ded9rVah0QE+O46XgBfDI/CYzO X-Received: by 2002:a63:69c9:: with SMTP id e192-v6mr14185878pgc.143.1539118249020; Tue, 09 Oct 2018 13:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539118248; cv=none; d=google.com; s=arc-20160816; b=CT74TGLoV0I/vP5uy+pWbuxkEdPbuwGJPCuhCjQ8/7YuWRhuZuxRFEkYm4Ft3c8qEf wLbiL7XGXlUhZo0TwEWndG9OXnFNiC2c20trxvzR38QdwtGKUFKKO7/8pabXPWJu7OZ1 gU26BJAvSGAmF8i9bDMR/cgDx5gR4926DAF9MdRScNZJH8RUbEa3d+N5oNA7LRlZOzA8 r4NiDmXKV+g8xaDGScL7t0mmW4xtmCGTWnDd+9JyPt/o9LcATXQTkq8iYWRZvcRHZStM zDvVxytfrgxLLMdHXu47CYKCT8nDpGFeTnpXIVbAcf4r9KqBsR7fwsSuO4uWReDEDadv dbOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=JkLNlJAZ6sSR2+4dv37LRhlP6LQ4182o5am8KxifU3U=; b=XKi3CMC9821D/VvddJBti+ybBncLLE63Ew4fiuAJFRfEaEhGaMohsTnRBNYElo0PAf 2/e1scwnvtv8RtL0/0Xqq6JpyLU/9dzzIXR//9scEg50ys6xdMuxpz4k2fQUaVxjjL6f 4Vohck0Q+Wnl6gC7RoxHFziwRP+QlXtuxNqhuyc8ycqgefjDBoO7o+gOwfpx4I3ihOnB a+ELQooAh8tNQTmK3HBE0Ir1FRygWm5isQk3V+4FUpAXb7xMAJuzU+gQE7ibHFiILQ+e oFak+OUDtyf00Ke3r2FXkWfejqwS1Jq698825EB+9CBAcICt/28trWz0fiL6vcqUrb3c bfhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GmgruCnQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p188-v6si24192768pfg.197.2018.10.09.13.50.33; Tue, 09 Oct 2018 13:50:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GmgruCnQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727803AbeJJD2e (ORCPT + 99 others); Tue, 9 Oct 2018 23:28:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:39310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726613AbeJJD2d (ORCPT ); Tue, 9 Oct 2018 23:28:33 -0400 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 51E572151C for ; Tue, 9 Oct 2018 20:09:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539115796; bh=EImMYQIQtriU1M+LjeP2cd8rj0C1xYjS3CeZrgu+T9I=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GmgruCnQ9SGGkwBuvtliEKePrJCh0Uf0aYfAEaVlC8cZxEey24kq7odznhUYrz8bK w8tjsoCT2eUwtSQolq02BHUUiB9A9lDazs/fTybC5FfnjJiAGe06VXBm/GMOUIjmQp /Gh3+vZuN7hAXh0uyYUSWXHu1L35Q7L/5ZmYw25I= Received: by mail-wm1-f42.google.com with SMTP id a8-v6so3319345wmf.1 for ; Tue, 09 Oct 2018 13:09:56 -0700 (PDT) X-Gm-Message-State: ABuFfohlJv+C+flVhmJhxWJxGaTjKYoMfVu0NVDEgEIBSLpfXZ9Wy+ok LFlPsTIKpRdzn96jUseCIWwDDPpPOhcuvB3iYqRm9g== X-Received: by 2002:a1c:f312:: with SMTP id q18-v6mr3074861wmq.14.1539115794622; Tue, 09 Oct 2018 13:09:54 -0700 (PDT) MIME-Version: 1.0 References: <87k1mycfju.fsf@vitty.brq.redhat.com> <20181004081100.GI19272@hirez.programming.kicks-ass.net> <20181004193150.GQ19272@hirez.programming.kicks-ass.net> <499807AB-E779-40C3-AA3F-E8C77A7770EC@amacapital.net> <20181006202731.GC7129@amt.cnet> <20181008152650.GB27822@amt.cnet> <20181008193632.GA31729@amt.cnet> In-Reply-To: <20181008193632.GA31729@amt.cnet> From: Andy Lutomirski Date: Tue, 9 Oct 2018 13:09:42 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [patch 00/11] x86/vdso: Cleanups, simmplifications and CLOCK_TAI support To: Marcelo Tosatti Cc: Andrew Lutomirski , Peter Zijlstra , Vitaly Kuznetsov , Thomas Gleixner , Paolo Bonzini , Radim Krcmar , Wanpeng Li , LKML , X86 ML , Matt Rickard , Stephen Boyd , John Stultz , Florian Weimer , KY Srinivasan , devel@linuxdriverproject.org, Linux Virtualization , Arnd Bergmann , Juergen Gross Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 9, 2018 at 8:28 AM Marcelo Tosatti wrote: > > On Mon, Oct 08, 2018 at 10:38:22AM -0700, Andy Lutomirski wrote: > > On Mon, Oct 8, 2018 at 8:27 AM Marcelo Tosatti wrote: > > I read the comment three more times and even dug through the git > > history. It seems like what you're saying is that, under certain > > conditions (which arguably would be bugs in the core Linux timing > > code), > > I don't see that as a bug. Its just a side effect of reading two > different clocks (one is CLOCK_MONOTONIC and the other is TSC), > and using those two clocks to as a "base + offset". > > As the comment explains, if you do that, can't guarantee monotonicity. > > > actually calling ktime_get_boot_ns() could be non-monotonic > > with respect to the kvmclock timing. But get_kvmclock_ns() isn't used > > for VM timing as such -- it's used for the IOCTL interfaces for > > updating the time offset. So can you explain how my patch is > > incorrect? > > ktime_get_boot_ns() has frequency correction applied, while > reading masterclock + TSC offset does not. > > So the clock reads differ. > Ah, okay, I finally think I see what's going on. In the kvmclock data exposed to the guest, tsc_shift and tsc_to_system_mul come from tgt_tsc_khz, whereas master_kernel_ns and master_cycle_now come from CLOCK_BOOTTIME. So the kvmclock and kernel clock drift apart at a rate given by the frequency shift and then suddenly agree again every time the pvclock data is updated. Is there a reason to do it this way?