From patchwork Mon Jul 9 09:22:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 10514121 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4EDAF6032C for ; Mon, 9 Jul 2018 09:23:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F23F28A62 for ; Mon, 9 Jul 2018 09:23:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 437CC28A69; Mon, 9 Jul 2018 09:23:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B65B28A62 for ; Mon, 9 Jul 2018 09:23:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932742AbeGIJXB (ORCPT ); Mon, 9 Jul 2018 05:23:01 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:39426 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932241AbeGIJW7 (ORCPT ); Mon, 9 Jul 2018 05:22:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; 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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=KWOj7qFmFEURuu4N1y/wrecXj0PqeZ+USMPyxWQVuRI=; b=HA8ketiFmix1gHSLIxLdHAOUp /t1N6aj78pVYgwOFjthqgb3r/2kmaaFLFWpPnBSK7R8a/gufAtmdLSdrJoFUCYfK1GJvyYS+UFGrA 1QZ3CRDXil9dnL0iCqUfU65r8DCH1t1bG3aeueclP4ZtHBxsgvDNTUxtfwdrTp8FGVO4EyeBn8tt2 nZ4GmNZVprDaJbVNYu83HpudQyiQr4yJBGAZJk00VkYsI4fZsp0JkbYcKFXXUymhh4Cq3gaxFREsJ vneb1BOCXkQBxX0+qlyjIOKFUeNh0xg1i9ZsxUUFR4/+CegXGd6+7PrjRy1RxAsu49BnoyVzvuY82 aWS2XAviA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcSNZ-0004VE-Cd; Mon, 09 Jul 2018 09:22:45 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id B80E72028932D; Mon, 9 Jul 2018 11:22:43 +0200 (CEST) Date: Mon, 9 Jul 2018 11:22:43 +0200 From: Peter Zijlstra To: Thomas Gleixner Cc: LKML , Paolo Bonzini , Radim Krcmar , Juergen Gross , Pavel Tatashin , steven.sistare@oracle.com, daniel.m.jordan@oracle.com, x86@kernel.org, kvm@vger.kernel.org Subject: [patch 8/7] x86/kvmclock: Avoid TSC recalibration Message-ID: <20180709092243.GG2476@hirez.programming.kicks-ass.net> References: <20180706161307.733337643@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180706161307.733337643@linutronix.de> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the host gives us a TSC rate, assume it is good and don't try and recalibrate things against virtual timer hardware. Signed-off-by: Peter Zijlstra (Intel) --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -140,7 +140,16 @@ static inline void kvm_sched_clock_init( */ static unsigned long kvm_get_tsc_khz(void) { - return pvclock_tsc_khz(this_cpu_pvti()); + unsigned long tsc_khz = pvclock_tsc_khz(this_cpu_pvti()); + + /* + * TSC frequency is reported by the host; calibration against (virtual) + * HPET/PM-timer in a guest is dodgy and pointless since the host already + * did it for us where required. + */ + setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ); + + return tsc_khz; } static void kvm_get_preset_lpj(void)