Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1604206rdb; Mon, 2 Oct 2023 15:10:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0e1RyyI5IFVgiFhxxj8L4YSH74Jfk/gSoF4KTJRAoFacVeM+1OtlQ4oiOG6SUZPee/J/6 X-Received: by 2002:a17:90a:ea12:b0:274:2523:fc7f with SMTP id w18-20020a17090aea1200b002742523fc7fmr10763898pjy.47.1696284645024; Mon, 02 Oct 2023 15:10:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696284645; cv=none; d=google.com; s=arc-20160816; b=W9g4lmIb+1eEo8MrS+aw9ZM+7G25KM6awkoFiB/AzwOz3bIUq8Ih5o94Wb1u78qkDh VHFfz8PuPZGMuxKFf3DCc5xSuPxunqLPd4jjPrTnco/GHK6S8Mz7pfr4yuZd5XkSi27k 8F/tWXwpzdMNR5BfoI5ZJvmsuZvgUOlkcbuIqoFy7IyvMdKw/0VzJ230MMJjxriOBVVQ 9ttX6PDOQhGuPDG3Vc+1Ux5vkHUM2hkp05YmJ3ibt564siHGMOJ9IXk2gU0NJvrH0UQd YL3Iv17qKeBmsD96ed+9QPCGsZkrrhNkVuBK+wqkEWJhRxm7+TpIjP2gPxqIZmdpt3cy 1jRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LauJpiU9vgGJKI+xHtCdZfyl14FEn4Hj7li+RFgP5pk=; fh=fn3qYB7CDyXP/F66+6WIPdbQ/DhuDz09svknY2cbl94=; b=TJcQa/7lkyYZY9N7axa2IJWRYGUdhOf9RmFqgHzdR2czfNsQ9+oz/TRL1podyVhxoF OW8MP8UWPiFA/g2c96PbA+s9Hv6qCFAs1VyZBoTdIVSSFQOokQ2tiINJiUSKU2ZPxl8K 1u2ERh8fVTWTDb/319j0JhIbke272zxr8X9ogZHaGq0mnsUaj4xiZuAeub+uIIXxguCA F+AE8/vz+uNdZ38fG6DqrsYXIApRZ7G6c6+mxJ8DGPJJ+RXvgXAU+RP1RRDKzZLEdh8X 8AlIuW0ZvAGV0KKRR6P2Z/XYbdb7ddSRwhQwRnzo2GNkORnjAzTIbDZA0BAwqCUfG0RT /Xnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=q2WKSjdu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id y13-20020a17090aa40d00b00274bdf87878si8428524pjp.166.2023.10.02.15.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 15:10:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=q2WKSjdu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id AF0508048D84; Mon, 2 Oct 2023 14:17:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229909AbjJBVRZ (ORCPT + 99 others); Mon, 2 Oct 2023 17:17:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbjJBVRY (ORCPT ); Mon, 2 Oct 2023 17:17:24 -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 BD1B9A4; Mon, 2 Oct 2023 14:17:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=LauJpiU9vgGJKI+xHtCdZfyl14FEn4Hj7li+RFgP5pk=; b=q2WKSjduqc6gNmUy5+PKB56DmA sO5XkEIeo9TmA9DcELYksbTAZJdotXfki4LFStfRDdRkzaF0coOJxj8BSjKb8yCKbSO8ejbDx+KQK 14P8x2caxCfxHcQmfpMwE7/cw/hKvHH2Z6PasExE/uuq57M1nxShgjPDTEJWYe9HhVAiN9ZOB9Ed4 KrJuDpOmHAdwimVlF0Lmfw3QFCkH48Ucp3R+gf4aHwoAxNFKdsHKRAzNjXaEW0wxxdGB2zZYwkvy7 gg2isWBwYhxL5v7isCEfvXu2QnRfANgtg2WCPi53fmVyfT2BmxatJu/Zp5YkYJDnwQVW7diG6HmZt IGQkmMww==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qnQHa-009IId-2B; Mon, 02 Oct 2023 21:16:53 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 81288300454; Mon, 2 Oct 2023 23:16:51 +0200 (CEST) Date: Mon, 2 Oct 2023 23:16:51 +0200 From: Peter Zijlstra To: Sean Christopherson Cc: Dongli Zhang , David Woodhouse , 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: Re: [PATCH RFC 1/1] KVM: x86: add param to update master clock periodically Message-ID: <20231002211651.GA3774@noisy.programming.kicks-ass.net> 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> <20231002210607.GD27267@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231002210607.GD27267@noisy.programming.kicks-ass.net> X-Spam-Status: No, score=-0.9 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 agentk.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 (agentk.vger.email [0.0.0.0]); Mon, 02 Oct 2023 14:17:41 -0700 (PDT) On Mon, Oct 02, 2023 at 11:06:07PM +0200, Peter Zijlstra wrote: > On Mon, Oct 02, 2023 at 11:18:50AM -0700, Sean Christopherson wrote: > > +PeterZ > > > > Thomas and Peter, > > > > We're trying to address an issue where KVM's paravirt kvmclock drifts from the > > host's TSC-based monotonic raw clock because of historical reasons (at least, AFAICT), > > even when the TSC is constant. Due to some dubious KVM behavior, KVM may sometimes > > re-sync kvmclock against the host's monotonic raw clock, which causes non-trivial > > jumps in time from the guest's perspective. > > > > Linux-as-a-guest demotes all paravirt clock sources when the TSC is constant and > > nonstop, and so the goofy KVM behavior isn't likely to affect the guest's clocksource, > > but the guest's sched_clock() implementation keeps using the paravirt clock. > > > > Irrespective of if/how we fix the KVM host-side mess, using a paravirt clock for > > the scheduler when using a constant, nonstop TSC for the clocksource seems at best > > inefficient, and at worst unnecessarily complex and risky. > > > > Is there any reason not to prefer native_sched_clock() over whatever paravirt > > clock is present when the TSC is the preferred clocksource? > > I see none, that whole pv_clock thing is horrible crap. In fact, I don't really see a reason to ever use pv_clock, even on non-constant TSC. The sched_clock machinery used on x86 (and ia64 at some point) reverts to tick-based + 'TSC-with-monotonicity-filter refinement' once it detects the TSC is crap. And that should work in a guest too I suppose. Also, I really should clean all that up -- it's all static_key based, but I think I can do a saner version with static_call. But that's stuck somewhere on the eternal todo list.