Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1450291rdg; Sat, 14 Oct 2023 02:50:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFArlUKTOK2GZqJ84SgPcdDXRetyND9cnd+m42HvWFQLXEqGmIHXhGFjbN8+hhsSCrZx6/f X-Received: by 2002:a05:6808:2189:b0:3a9:7634:23f9 with SMTP id be9-20020a056808218900b003a9763423f9mr39625109oib.12.1697277030761; Sat, 14 Oct 2023 02:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697277030; cv=none; d=google.com; s=arc-20160816; b=G1bsx0IdULY79MnAmiu0nfToZNwgBmi/ub1wPa2yU3apVfsQbA89HxyrzqhqU2MV7v yg23jVwZ2IaKbaTUERe0SsBarc7vp45o8p0JBEHZ+Fnj20hJJ3C0QXoUau2iTwJD6ptU Zm3t5he0817Zj5cCf455v9VCzl53An5BKYJmb21V29tmqDy/arX9O7WlNtSEFRLZ/Wo4 iHThkJabsnvZ/Ed0Qi9cnYPEUgj8FyJfTkQJn2P1yrJc6wLzfMsmCndEFH2E0aiL3bwE 23JZd6ZSKOii44QtM/BJEQX60HPTz+uRHtPLhw8hvPdPF4smCocVuzo13vVGNdVtV7gq Cziw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:references:in-reply-to:user-agent:subject:cc:to:from :date:dkim-signature; bh=B/87SAaBNpjhcH93Fzv1JgJikdrvTdlmfDD4O28z/QY=; fh=THcGyYxCWps6KPTFAo1ZB85GBKArbBMIojNHttqNstA=; b=SAJz11lX1SJ1Gc1sWLXI2cWcPEP3lkf+s9TZlcdH8v52sRaeoYr/zLuEnz0cbCWffU 2DYo+1ea8xwVW4BWRTKev0rbjaqpp9GoR2c5UkF2wbpGc7elKcy6TJEF0tC+9VeRQ/hF Hb55amqB1TuSPBhaH8k+qKat54j9+kWjXgIYlgN7zUXGzSosC3YdKLG4oSaSfA58Mhu/ sPsd7atj79uhPlQFxLy9PWiNLsnJXe2Ae36C58EXtSnELrwXsOKgEbCogjcI+S1vWMtJ gREAG3xMLhshB46ioADFVCXke3Fm39iKreoCZU164Ly3J2kuJaCXk3YdY3+e34NG0wI+ etsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="HyeDSIA/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id i3-20020a639d03000000b005b2d044af30si624633pgd.480.2023.10.14.02.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 02:50:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="HyeDSIA/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 40B8680D88D1; Sat, 14 Oct 2023 02:50:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232994AbjJNJtz (ORCPT + 99 others); Sat, 14 Oct 2023 05:49:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231377AbjJNJty (ORCPT ); Sat, 14 Oct 2023 05:49:54 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBFC0B7; Sat, 14 Oct 2023 02:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:Message-ID:References:In-Reply-To:Subject:CC:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=B/87SAaBNpjhcH93Fzv1JgJikdrvTdlmfDD4O28z/QY=; b=HyeDSIA/T1QZrVocc24JkH3TZ9 Exw1T8DjomzMLFhEDzvu+hDo2DOduJj7PFMOnGdcm1rekt4q3ql2l1erjCVS4hw66x67770soASXD ZWErq0fisKxAp48r/QlZbb/6clCOVoTvSa3NlUZZ+JV0W6s8kZ3BzZN6X28sIuA1ITh1/86j2/qVt ytuVoZjlyTO52GoNOSZMWODdlufhBS+fnAHMVn3fgtL07FDycuRZS8ACle/sjAXkB6yI7nuO6g4iZ iwOSw/V2q9V/djzrLTJuWrjiMtDM0708bfFKNKMAv1aLQhl81AM6pLHMCHwkJfhwxUmsaDvUH0N/E B11hCcHg==; Received: from [2a00:23ee:1950:579c:f76b:d9be:e375:650d] (helo=[IPv6:::1]) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qrbGw-003ah4-2a; Sat, 14 Oct 2023 09:49:29 +0000 Date: Sat, 14 Oct 2023 10:49:15 +0100 From: David Woodhouse To: Sean Christopherson , Dongli Zhang CC: 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 Subject: =?US-ASCII?Q?Re=3A_=5BPATCH_RFC_1/1=5D_KVM=3A_x86=3A_add_par?= =?US-ASCII?Q?am_to_update_master_clock_periodically?= User-Agent: K-9 Mail for Android In-Reply-To: References: <9975969725a64c2ba2b398244dba3437bff5154e.camel@infradead.org> <34057852-f6c0-d6d5-261f-bbb5fa056425@oracle.com> <8f3493ca4c0e726d5c3876bb7dd2cfc432d9deaa.camel@infradead.org> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SRS-Rewrite: SMTP reverse-path rewritten from by desiato.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Sat, 14 Oct 2023 02:50:28 -0700 (PDT) On 14 October 2023 00:26:45 BST, Sean Christopherson = wrote: >> 2=2E Suppose the KVM host has been running for long time, and the drift= between >> two domains would be accumulated to super large? (Even it may not intro= duce >> anything bad immediately) > >That already happens today, e=2Eg=2E unless the host does vCPU hotplug or= is using >XEN's shared info page, masterclock updates effectively never happen=2E = And I'm >not aware of a single bug report of someone complaining that kvmclock has= drifted >from the host clock=2E The only bug reports we have are when KVM trigger= s an update >and causes time to jump from the guest's perspective=2E I've got reports about the Xen clock going backwards, and also about it dr= ifting over time w=2Er=2Et=2E the guest's TSC clocksource so the watchdog i= n the guest declares its TSC clocksource unstable=2E=20 I don't understand *why* we update the master lock when we populate the Xe= n shared info=2E Or add a vCPU, for that matter=2E=20 >> The idea is to never update master clock, if tsc is stable (and masterc= lock is >> already used)=2E > >That's another option, but if there are no masterclock updates, then it s= uffers >the exact same (theoretical) problem as #2=2E And there are real downsid= es, e=2Eg=2E >defining when KVM would synchronize kvmclock with the host clock would be >significantly harder=2E=2E=2E I thought the definition of such an approach would be that we *never* resy= nc the kvmclock to anything=2E It's based purely on the TSC value when the = guest started, and the TSC frequency=2E The pvclock we advertise to all vCP= Us would be the same, and would *never* change except on migration=2E (I guess that for consistency we would scale first to the *guest* TSC and = from that to nanoseconds=2E) If userspace does anything which makes that become invalid, userspace gets= to keep both pieces=2E That includes userspace having to deal with host su= spend like migration, etc=2E