Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2288361rdb; Tue, 3 Oct 2023 17:07:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHUWFzBVRAAM+A+LLoW6nn/egxFbEO5G5N4vjo+yFypcV/jf073tqg5cbo5pkoD+vVVnTk8 X-Received: by 2002:a05:6300:8001:b0:15d:c1a8:c329 with SMTP id an1-20020a056300800100b0015dc1a8c329mr778262pzc.48.1696378061454; Tue, 03 Oct 2023 17:07:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696378061; cv=none; d=google.com; s=arc-20160816; b=z60KM8O8oj6X7A9c5JEZ2qP7fBNvSNmqyM1vthgBadHgiBA/V6qtI/QVc4yLs4Jyds +pVTLo25TZ5kY17KK6PUKL85d9KCQbXeCe3y2nqkp1RuFrBHwSKlQjHevkvt/ydTK2qI uQ6M43U6/OVwJorzZYVJ4kbH6GhMufICBPHZmqZQwx+2grZuvSpYp3Wrrb11+InlcMyE aEpX8BQNPVLYRnFIme0jTaQqWaY5L4P8qprSjkQtp7A0lUXuRLAqaePvXQCzXkdPacG2 KYTzml8G2qx7cRW7WkTUqmcXD3Ms+nS/naebz8a8T3RJ0lotPIFuIB0TzHJz0SkOvvEh lyKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=SCChu475pVfip1pDwbHdwIY6LAU4+An6h8yh5xS6rAg=; fh=kEwGWtJQc59vbmlm12aVprPFZ9WpoqRDDmJESEnXeTY=; b=sYG/YD4RAD8Me7WZuY7xl1r6+l/VfOzvbdr+Mm6VwMxSgHQNbaJia47xzkpG7CIZW/ xwXUeKCpjxTkGsP+LfbNbqv/ZMjBezhKUUtfpGP0gtU4SSrOZaRsqkSgr/aHtM+s8Sp0 rV1kU3E1Ol5nGdOPkzaqUqPZ7vxacOLfYHpNW5fB3kfGKCsOQH00JZ4/RhAHzix8T0Jx DNX5hDuukhDs9LMbtJOP8a7O+ic5Si8hcpr7XO2DxfPQZA3s0O4mPprYvGTkSJgaJrrc SLrRAZ0LO+UqNHhbmqXkX5a/jlE8RT8PXIX1CAhTkubGX0DXgav3NagKb5EyZJH+EEXu D10w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="VVNP/7yZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id n66-20020a632745000000b00578bb2502ccsi2483387pgn.407.2023.10.03.17.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 17:07:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="VVNP/7yZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 09E168122289; Tue, 3 Oct 2023 17:07:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232300AbjJDAH2 (ORCPT + 99 others); Tue, 3 Oct 2023 20:07:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229663AbjJDAH2 (ORCPT ); Tue, 3 Oct 2023 20:07:28 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E8C29B for ; Tue, 3 Oct 2023 17:07:25 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d81a47e12b5so2233282276.0 for ; Tue, 03 Oct 2023 17:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696378044; x=1696982844; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=SCChu475pVfip1pDwbHdwIY6LAU4+An6h8yh5xS6rAg=; b=VVNP/7yZCsM/EykEitOpJlpp+N5Ini1lWSwWuwk15sX3mRnxDwEA26zA7dtE3TXZ9o nCTK3RkO4YF80P0qsGKnUVBYyvDJEBjuraQeeNx6JyN1MHqJkhs/e2kRarX6jDD+XKzQ 4+R9ZpGsRi51BEKgbe1q07bFno+RH8eNZzdMKSf70eS6JAWMnUKW1q9z75UpnYbztDju 8kMMjoeS+CDhbNJy36AoSfKXMFbT0XgR7+EBmpSQto8BGuQfhAmSDjTNnT+2fbhC7KSo kyCiGkUuOK9Y1h8glyNpDUUs1u0wU03mPBP6fAyYdaWQYvI0AvgveKgtEzG/ynsCIHLK xNHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696378044; x=1696982844; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SCChu475pVfip1pDwbHdwIY6LAU4+An6h8yh5xS6rAg=; b=UUP79HrTfXy6M7DjoFCQKA9gOrgnQU69sn6HiucPezbXpJN2YtgH8SuRRRpjYShS0U Mg12pc3iPyL2qP+qBbEWbKoag0jF7111IL/Uc9lbIWqc+dlBBfVDFsm7LommzPpgvawE PNDAiO9MDFvTXXrrkvQ4Gfd6Tj711CmvyZyaTz5aC6P8stAy4vNYUcEdZbMoQFt6wz9u tiNJnwZX45+ERWkBs2lVtac3KDiim+hAfvWcVRGs07OUSqdptqmIlaT6dPYLQHgTLzPA wb9umqcd6ZOxYxw6UNcpKisaFz9kibU1lQ5bUqt99bh8ZXv/mFId4gYq7YC/eqR1HwB/ GHhg== X-Gm-Message-State: AOJu0YxER00EZmyAWi7e9zl5wWW9jUWWfRB+uscPEvwfiI22DXoH6r9a F9d0+tZiQhVUKitIvi0Rk3TLbUR086c= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:13cc:b0:d91:8876:2040 with SMTP id y12-20020a05690213cc00b00d9188762040mr11869ybu.5.1696378044229; Tue, 03 Oct 2023 17:07:24 -0700 (PDT) Date: Tue, 3 Oct 2023 17:07:22 -0700 In-Reply-To: <20EAA3C4-A9F4-4EC1-AE0C-D540CC2E024A@infradead.org> Mime-Version: 1.0 References: <20230926230649.67852-1-dongli.zhang@oracle.com> <377d9706-cc10-dfb8-5326-96c83c47338d@oracle.com> <36f3dbb1-61d7-e90a-02cf-9f151a1a3d35@oracle.com> <884aa233ef46d5209b2d1c92ce992f50a76bd656.camel@infradead.org> <52a3cea2084482fc67e35a0bf37453f84dcd6297.camel@infradead.org> <20EAA3C4-A9F4-4EC1-AE0C-D540CC2E024A@infradead.org> Message-ID: Subject: Re: [PATCH RFC 1/1] KVM: x86: add param to update master clock periodically From: Sean Christopherson To: David Woodhouse Cc: Dongli Zhang , Joe Jin , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 03 Oct 2023 17:07:38 -0700 (PDT) On Tue, Oct 03, 2023, David Woodhouse wrote: > > > On 3 October 2023 01:53:11 BST, Sean Christopherson wrote: > >I think there is still use for synchronizing with the host's view of time, e.g. > >to deal with lost time across host suspend+resume. > > > >So I don't think we can completely sever KVM's paravirt clocks from host time, > >at least not without harming use cases that rely on the host's view to keep > >accurate time. And honestly at that point, the right answer would be to stop > >advertising paravirt clocks entirely. > > > >But I do think we can address the issues that Dongli and David are obversing > >where guest time drifts even though the host kernel's base time hasn't changed. > >If I've pieced everything together correctly, the drift can be eliminated simply > >by using the paravirt clock algorithm when converting the delta from the raw TSC > >to nanoseconds. > > > >This is *very* lightly tested, as in it compiles and doesn't explode, but that's > >about all I've tested. > > Hm, I don't think I like this. Yeah, I don't like it either. I'll respond to your other mail with details, but this is a dead end anything. > You're making get_monotonic_raw() not *actually* return the monotonic_raw > clock, but basically return the kvmclock instead? And why? So that when KVM > attempts to synchronize the kvmclock to the monotonic_raw clock, it gets > tricked into actually synchronizing the kvmclock to *itself*? > > If you get this right, don't we have a fairly complex piece of code that has > precisely *no* effect? > > Can't we just *refrain* from synchronizing the kvmclock to *anything*, in the > CONSTANT_TSC case? Why do we do that anyway? > > (Suspend/resume, live update and live migration are different. In *those* > cases we may need to preserve both the guest TSC and kvmclock based on either > the host TSC or CLOCK_TAI. But that's different.) The issue is that the timekeeping code doesn't provide a notification mechanism to *just* get updates for things like suspend/reume. We could maybe do something in KVM like unregister the notifier if the TSC is constant, and manually refresh on suspend/resume. But that's pretty gross too, and I'd definitely be concerned that we missed something.