From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [patch 4/8] KVM: x86: replace hrtimer based timer emulation Date: Wed, 8 Jul 2009 15:58:19 +0300 Message-ID: <20090708125819.GM28046@redhat.com> References: <20090706015511.923596553@localhost.localdomain> <20090706015812.786509491@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx2.redhat.com ([66.187.237.31]:39588 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751149AbZGHM6X (ORCPT ); Wed, 8 Jul 2009 08:58:23 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n68CwMVg023225 for ; Wed, 8 Jul 2009 08:58:22 -0400 Content-Disposition: inline In-Reply-To: <20090706015812.786509491@localhost.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: Excellent patch series. On Sun, Jul 05, 2009 at 10:55:15PM -0300, Marcelo Tosatti wrote: > int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu) > { > - int ret; > + ktime_t now, expires; > > - ret = pit_has_pending_timer(vcpu); > - ret |= apic_has_pending_timer(vcpu); > + expires = kvm_vcpu_next_timer_event(vcpu); > + now = ktime_get(); > + if (expires.tv64 <= now.tv64) { > + if (kvm_arch_interrupt_allowed(vcpu)) > + set_bit(KVM_REQ_UNHALT, &vcpu->requests); You shouldn't unhalt vcpu here. Not every timer event will generate interrupt (vector can be masked in pic/ioapic) or timer event can generate NMI instead of interrupt. Leaving this code out probably means that you can't remove kvm_inject_pending_timer_irqs() call from __vcpu_run(). > + return 1; > + } > > - return ret; > + return 0; > } > EXPORT_SYMBOL(kvm_cpu_has_pending_timer); > -- Gleb.