From patchwork Mon Feb 24 15:42:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 25207 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 94E0D2066E for ; Mon, 24 Feb 2014 15:42:53 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id wo20sf6982747obc.4 for ; Mon, 24 Feb 2014 07:42:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=Y+RYfAYjn64mB+YOV2sxi5/Lu45191ZOCp1NBC12tKs=; b=KV/feU06/wR1ToGPIgGvHeg1lfSK8ZKZnibKBxRof0aaRHNO6KFUPmvKXHjpJ7w2qX tu1Svlw04bji+4tOy4i2zlFsV2VWnHuqR8E0j8WcZLYwLus+YteycMQ3xGFjob/VLU9/ G3334CI6+O+YJhp8zt2R8elCsk7mEFYHA8u2SyX0YB8+5pD/xNjpADOMb+QydB9+/DWe PpXxXQnDYHrNaYw3YrQUGMSorI4fo15IfpU6D2UFnNOu2Xnv5cThttjmRO3JhqH+Ag7g xbOlgUd36HYBO+rk3Cyc25jzNvmV4gf0OJvJEkazai5DlCsIyzgtNy0EI/fBCRoA+PVK NHmg== X-Gm-Message-State: ALoCoQkmXIP+dXAOaGK/Io0AnWC2BXBaZZiFr+HgQTC/ZTb9edcS7lvVT36xGqE79Oq3Gv7xc34D X-Received: by 10.50.164.198 with SMTP id ys6mr9628882igb.2.1393256573117; Mon, 24 Feb 2014 07:42:53 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.180 with SMTP id z49ls2066224qgd.59.gmail; Mon, 24 Feb 2014 07:42:53 -0800 (PST) X-Received: by 10.52.63.233 with SMTP id j9mr300196vds.69.1393256573000; Mon, 24 Feb 2014 07:42:53 -0800 (PST) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id n15si5932596vcy.102.2014.02.24.07.42.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 24 Feb 2014 07:42:52 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jy13so5946726veb.41 for ; Mon, 24 Feb 2014 07:42:52 -0800 (PST) X-Received: by 10.220.191.134 with SMTP id dm6mr13203155vcb.16.1393256572891; Mon, 24 Feb 2014 07:42:52 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp70015vcz; Mon, 24 Feb 2014 07:42:52 -0800 (PST) X-Received: by 10.68.136.162 with SMTP id qb2mr444206pbb.88.1393256572045; Mon, 24 Feb 2014 07:42:52 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wh4si325157pbc.357.2014.02.24.07.42.51; Mon, 24 Feb 2014 07:42:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753328AbaBXPmj (ORCPT + 26 others); Mon, 24 Feb 2014 10:42:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:9250 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753294AbaBXPmh (ORCPT ); Mon, 24 Feb 2014 10:42:37 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1OFgbj7027732 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 24 Feb 2014 10:42:37 -0500 Received: from hawk.usersys.redhat.com.com (dhcp-1-243.brq.redhat.com [10.34.1.243]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s1OFgZhW016032; Mon, 24 Feb 2014 10:42:35 -0500 From: Andrew Jones To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: mtosatti@redhat.com, pbonzini@redhat.com Subject: [PATCH] x86: kvm: fix unstable_tsc boot Date: Mon, 24 Feb 2014 16:42:29 +0100 Message-Id: <1393256549-7743-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: drjones@redhat.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When the tsc is marked unstable on the host it causes global clock updates to be requested each time a vcpu is loaded, nearly halting all progress on guests with a large number of vcpus. Fix this by only requesting a local clock update unless the vcpu is migrating to another cpu. Signed-off-by: Andrew Jones --- arch/x86/kvm/x86.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6530019116b0d..ea716a162b4a3 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2781,15 +2781,18 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) vcpu->arch.last_guest_tsc); kvm_x86_ops->write_tsc_offset(vcpu, offset); vcpu->arch.tsc_catchup = 1; + set_bit(KVM_REQ_CLOCK_UPDATE, &vcpu->requests); } + } + + if (unlikely(vcpu->cpu != cpu)) { /* * On a host with synchronized TSC, there is no need to update * kvmclock on vcpu->cpu migration */ if (!vcpu->kvm->arch.use_master_clock || vcpu->cpu == -1) kvm_make_request(KVM_REQ_GLOBAL_CLOCK_UPDATE, vcpu); - if (vcpu->cpu != cpu) - kvm_migrate_timers(vcpu); + kvm_migrate_timers(vcpu); vcpu->cpu = cpu; }