From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH v2] KVM: x86: reset lapic_timer.expired_tscdeadline at SET_LAPIC time Date: Tue, 21 Jun 2016 08:35:34 -0300 Message-ID: <20160621113531.GA11032@amt.cnet> References: <20160617234126.GA24514@amt.cnet> <6bc78368-d559-fa09-7e77-389b0e87d695@gmail.com> <20160620130531.GA8139@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Alan Jenkins , kvm-devel To: Paolo Bonzini Return-path: Received: from mx1.redhat.com ([209.132.183.28]:37804 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751059AbcFULmv (ORCPT ); Tue, 21 Jun 2016 07:42:51 -0400 Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Jun 21, 2016 at 09:50:54AM +0200, Paolo Bonzini wrote: > > > On 20/06/2016 15:05, Marcelo Tosatti wrote: > > > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index ea306ad..89be6e9 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -2991,6 +2991,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu, > > { > > kvm_apic_post_state_restore(vcpu, s); > > update_cr8_intercept(vcpu); > > + vcpu->arch.apic->lapic_timer.expired_tscdeadline = 0; > > > > I think this is not correct. You have programmed the host timer to an > early value when kvm_apic_post_state_restore called start_apic_timer. > > I think that: > > 1) post_state_restore should cancel the timer and clear > lapic_timer.pending before writing the registers, not afterwards. > lapic_timer.expired_tscdeadline can be cleared at the same time. > > 2) kvm_write_tsc should do the same and restart the timer afterwards. > > Thanks, > > Paolo Actually, the max should deal with the problem Alan is having with vmload as well (one delay of tenths of microseconds, or 0, per vmload should be irrelevant).