From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH][RFC] Use return value from kvm_set_irq() to re-inject PIT interrupts. Date: Wed, 26 Aug 2009 16:50:40 +0300 Message-ID: <20090826135040.GF30093@redhat.com> References: <20090824120623.GC30093@redhat.com> <20090824163256.GA8653@amt.cnet> <20090824171646.GA11762@redhat.com> <20090824174427.GA10311@amt.cnet> <20090824181905.GB11762@redhat.com> <20090826124348.GA32235@amt.cnet> <20090826131917.GE30093@redhat.com> <20090826133842.GB676@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, avi@redhat.com, zamsden@redhat.com To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:41943 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757403AbZHZNuk (ORCPT ); Wed, 26 Aug 2009 09:50:40 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7QDog5S008856 for ; Wed, 26 Aug 2009 09:50:42 -0400 Content-Disposition: inline In-Reply-To: <20090826133842.GB676@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Aug 26, 2009 at 10:38:42AM -0300, Marcelo Tosatti wrote: > > > > > If you don't have a host timer emulating the guest PIT, to periodically > > > > > bang on kvm_set_irq, how do you know when to attempt reinjection? > > > > > > > > > > You keep calling kvm_set_irq on every guest entry to figure out when > > > > > reinjection is possible? > > > > If we have timer to inject then yes. It is relatively cheap. Most of the > > > > time pending count will be zero. > > > > > > Won't work with non-tick-based emulation on the host. > > Why? This is the most important point, can you elaborate? > > >From http://www.mail-archive.com/kvm@vger.kernel.org/msg18644.html. > > An injectable timer interrupt is defined by: > > - time(now) >= time(next_expiration) > - Previous timer interrupt has been acked (thus we can inject). > > The thing is, sure you can drop ack notifiers and check IRR > on every guest entry, but why bother if you can receive an > asynchronous notification? > > Would you prefer to replace > > + if (!ktimer->can_inject) > > With > kvm_set_irq() > > ? > > Not relatively cheap. Most of the times time(now) will be less then time(next_expiration) so on most entries kvm_set_irq() will not be called at all. When interrupt has to be injected I prefer to try to inject it ASAP. PIC and APIC effectively have 2 element interrupt queue (irr/isr) so injection may succeed even though ack was not yet received. -- Gleb.