Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp485632rdb; Thu, 19 Oct 2023 09:47:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlZ0+Zo6stn/Ffyhls8zrh4P4KnVIAroebjx6FyRxi1a/o5lWKqNU3TxJ5WAfrPhGgHuQY X-Received: by 2002:a17:902:e80e:b0:1ca:2330:196a with SMTP id u14-20020a170902e80e00b001ca2330196amr3332469plg.6.1697734034260; Thu, 19 Oct 2023 09:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697734034; cv=none; d=google.com; s=arc-20160816; b=d6SraASnteHqLzUmezRstvFI3L6h614If7Jwut5VNoRxuNLrYQDmtaJbA/5M6T9ue0 K1YNCbWb7XdEgUQTGjOl5qb1CG4PsjrOpDBzuJwm+nHb3m8eJ7SsDgmpX6ZJk4EN+8ay TOkUIU6r8G53GLUe3ZLL5/kk7+EbANolYhloTB6sj6skqIK3v1526HmQItGO0dd96k+u p6RdovEZWg3r25RGbrvUsIQWocWcyfTv86sBJKTj+huCjD+dIjGn1DWmDv2AvoIY81ZV ehfT7rkUn41t3uc1IqfxzGg13+3/q06E7ODXCTeUP0jThn7oQDzuzstQdZAUgzjB0OrV iRZQ== 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=TpEPzMpbmRE7S67/u7J3M2Dti06L1rP8ZIHmBIwQBxQ=; fh=lmqkWW03h3TaA3fYSDhmVRqmuipqLUebKkwKVvIArUk=; b=0TANNpQcQ9XcNx6VrHQICT2ujCr9VPB6wJ8RA2M3ahdrJ2oWDK7qM5WGFhadO/90nW 5WrZkZUlVoa6hqh88jYAgVr8XTxrBIIcULa5ysZSP61NoDVuMx+pzahb4xUcTJ3y44UF bF7BuJ5xNyvTkcyD6LtFa49j324F0u9B3eDAle+xY6k2zkf+h0Ody3XGHV2bPyBZQsy2 p1FL1cci3XVozJZkoYzETxwPpj+mJZ5rs6KIHpr+vHRUKvll27xjhvCohlZJY2pVBJgx OzKTy7oogureYQ4UqgEoJNuyZu+TDQMHQWoYdbFQK7jdqbvzzcP0LRj+vNEjKuccEj78 /pEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=oRdsyrrT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id h14-20020a170902f54e00b001b829a32f2dsi2714810plf.457.2023.10.19.09.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 09:47:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=oRdsyrrT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 6867F828F4FF; Thu, 19 Oct 2023 09:47:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235465AbjJSQqu (ORCPT + 99 others); Thu, 19 Oct 2023 12:46:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231601AbjJSQqs (ORCPT ); Thu, 19 Oct 2023 12:46:48 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 793A413E for ; Thu, 19 Oct 2023 09:46:45 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-59b5a586da6so8280097b3.1 for ; Thu, 19 Oct 2023 09:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697734004; x=1698338804; 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=TpEPzMpbmRE7S67/u7J3M2Dti06L1rP8ZIHmBIwQBxQ=; b=oRdsyrrTg/a/sxyEmhjry+QyhUC2XFHXJt8eVHcq8zN+egLarC6Ra3fjwGdpaCY/0j CUulr1Iow+3ani9thHw6DryW2JeMSSA58xEMNU1XSYuq0HOPRQkqeriOE06GUL4G+d+V 406W0OFbCZ16oc93zH1DgRgdowLa28o/6Uhxot/k/H4eGBIL2l0BKPW0hwYuLRcRm8sN JNV0kZGDDHYMYwX9d94C0w9Z2PhoWFK6yNCWtD8nT07BzO6qwtPHd45pw/ikUvqc+KXT cWKLAyvWK2O/r7OLUVezLXO1yPrl1OcTloqhEziIw9k89tIsjrHCN0Sz+VVyFn0hEjVQ NlBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697734004; x=1698338804; 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=TpEPzMpbmRE7S67/u7J3M2Dti06L1rP8ZIHmBIwQBxQ=; b=WoUWl0MlM7Oa2t/59Y7kZ7Hkpe7jWUcuUXQLBfp3t46sr06eOTbuSvlN7JNV9pjmsG dUompE5nyz7LvKzIvt7tblraMsB3CTiGw3zXwg6V+XwA8DeElXqUc3QjpiR1Ia+AVx8a ZVGNifLYA/VtrFZalq8Fg45RcNy9lKcbROVfL6UGE3zkw/bp4NZHsXVFdJqtMPt/1jYF oLTakPYdH0lI6n4l29QvRWC8HknLzoO7XU/TBPbTfkDhjxCVCYn6iBG2CznY2Zfy/Wjc JoookyBY71iM8jXfxNUEWvJluc8riMXRNnVGS8Msx3mB19q5UxQAWwZCdvVxuvjH4IEN T3yg== X-Gm-Message-State: AOJu0YzGkmfygNcjQjQ0VXbvt3zZFxuwisQH+xlCu/bH7heKUhgzuC+P acfkyUlJ8Ga37SnfMNCKHjl+Kv4ra8c= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:4fcb:0:b0:5a7:b4d5:5f27 with SMTP id d194-20020a814fcb000000b005a7b4d55f27mr63990ywb.5.1697734004668; Thu, 19 Oct 2023 09:46:44 -0700 (PDT) Date: Thu, 19 Oct 2023 09:46:43 -0700 In-Reply-To: <2f1459d7c3e3e81cdca931e104c3ade71dfcfee5.camel@infradead.org> Mime-Version: 1.0 References: <20231018221123.136403-1-dongli.zhang@oracle.com> <87ttqm6d3f.fsf@redhat.com> <2f1459d7c3e3e81cdca931e104c3ade71dfcfee5.camel@infradead.org> Message-ID: Subject: Re: [PATCH RFC 1/1] x86/paravirt: introduce param to disable pv sched_clock From: Sean Christopherson To: David Woodhouse Cc: Vitaly Kuznetsov , Dongli Zhang , x86@kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, pv-drivers@vmware.com, xen-devel@lists.xenproject.org, linux-hyperv@vger.kernel.org, jgross@suse.com, akaher@vmware.com, amakhalov@vmware.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, pbonzini@redhat.com, wanpengli@tencent.com, peterz@infradead.org, joe.jin@oracle.com, boris.ostrovsky@oracle.com, linux-kernel@vger.kernel.org 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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 19 Oct 2023 09:47:11 -0700 (PDT) On Thu, Oct 19, 2023, David Woodhouse wrote: > On Thu, 2023-10-19 at 08:40 -0700, Sean Christopherson wrote: > > > If for some 'historical reasons' we can't revoke features we can always > > > introduce a new PV feature bit saying that TSC is preferred. > > Don't we already have one? It's the PVCLOCK_TSC_STABLE_BIT. Why would a > guest ever use kvmclock if the PVCLOCK_TSC_STABLE_BIT is set? > > The *point* in the kvmclock is that the hypervisor can mess with the > epoch/scaling to try to compensate for TSC brokenness as the host > scales/sleeps/etc. > > And the *problem* with the kvmclock is that it does just that, even > when the host TSC hasn't done anything wrong and the kvmclock shouldn't > have changed at all. > > If the PVCLOCK_TSC_STABLE_BIT is set, a guest should just use the guest > TSC directly without looking to the kvmclock for adjusting it. > > No? No :-) PVCLOCK_TSC_STABLE_BIT doesn't provide the guarantees that are needed to use the raw TSC directly. It's close, but there is at least one situation where using TSC directly even when the TSC is stable is bad idea: when hardware doesn't support TSC scaling and the guest virtual TSC is running at a higher frequency than the hardware TSC. The guest doesn't have to worry about the TSC going backwards, but using the TSC directly would cause the guest's time calculations to be inaccurate. And PVCLOCK_TSC_STABLE_BIT is also much more dynamic as it's tied to a given generation/sequence. E.g. if KVM stops using its masterclock for whatever reason, then kvm_guest_time_update() will effectively clear PVCLOCK_TSC_STABLE_BIT and the guest-side __pvclock_clocksource_read() will be forced to do a bit of extra work to ensure the clock is monotonically increasing.