From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH 2/2] KVM: x86: fix maintaining of kvm_clock stability on guest CPU hotplug Date: Thu, 6 Apr 2017 19:25:13 +0200 Message-ID: <20170406172512.GA23559@potion> References: <1491466125-16988-1-git-send-email-dplotnikov@virtuozzo.com> <1491466125-16988-3-git-send-email-dplotnikov@virtuozzo.com> <20170406171120.GK6369@potion> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: pbonzini@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org, rkagan@virtuozzo.com, den@virtuozzo.com To: Denis Plotnikov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:42154 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934049AbdDFRZS (ORCPT ); Thu, 6 Apr 2017 13:25:18 -0400 Content-Disposition: inline In-Reply-To: <20170406171120.GK6369@potion> Sender: kvm-owner@vger.kernel.org List-ID: 2017-04-06 19:11+0200, Radim Krčmář: > 2017-04-06 11:08+0300, Denis Plotnikov: >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> @@ -1455,15 +1455,23 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr) >> elapsed = ns - kvm->arch.last_tsc_nsec; >> >> if (vcpu->arch.virtual_tsc_khz) { >> - u64 tsc_exp = kvm->arch.last_tsc_write + >> - nsec_to_cycles(vcpu, elapsed); >> - u64 tsc_hz = vcpu->arch.virtual_tsc_khz * 1000LL; >> - /* >> - * Special case: TSC write with a small delta (1 second) of virtual >> - * cycle time against real time is interpreted as an attempt to >> - * synchronize the CPU. >> - */ >> - synchronizing = data < tsc_exp + tsc_hz && data > tsc_exp - tsc_hz; >> + if ((data == 0) && msr->host_initiated) { And while I'm nitpicking ... the code would also be nicer without the parentheses around data.