public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: "Dong, Eddie" <eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: FW: [kvm-commits] KVM: Move interrupt injection out of	interruptdisabled section
Date: Thu, 18 Oct 2007 10:59:48 +0200	[thread overview]
Message-ID: <47172084.7020608@qumranet.com> (raw)
In-Reply-To: <10EA09EFD8728347A513008B6B0DA77A023EF534-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>

Dong, Eddie wrote:
>>>> previous irq injection, next injection will be refused with IRQ
>>>> window enabled. This is because current implementation will inject
>>>> exception earlier than irq injection and vmx_intr_assist doesn;t
>>>> know if previous injected event is external irq (and thus
>>>> overwrite) or exception. Guest will see lower priority irq get
>>>> injected rather than higher priority IRQ which
>>>> arrives later.
>>>>
>>>>
>>>>         
>> Well, the same thing happens with the code before this commit,
>> no?  If a
>>     
>
> Why? 
> The philosiphy here is that the vCPU may receive new virtual irqs,
> but it will not try to injected. From guest point of view, an old irq
> (say irq_lo) arrives earlier and right before the virtual instruction
> boundary,
> and thus get responsed, while the new high priority irq (irq_hi) arrives
> a little bit later than irq_lo, but right after the instruction boundary
> and thus couldn't preempt irq_lo.
>
> When guest response to irq_lo, eflag.if=0, so irq_hi can't be responsed
> at that time although it see irq_hi in IRR.
>
> That align with native where it uses micro-code.
>
> If we enable pirq before physical irq is delivered, current code has 
> obvious issue (see below comments too).
> If we insist to move virq deliver out of irq disable. Then we need to
> avoid 2nd injection of irq. But a big side effect is that frequently 
> higher priority irq such as NIC/IDE irq will arrive right after lower
> priority irq which will obviously hurt various benchmark and even
> correctness.
>
> I will argue the necessaity of this code movement. A VM
> Exit/Resume itself probably will block system responsibility 
> (can't deliver irq) in the level of 1K cycles, interrupt injection is
> clearly far less than this granularity. Probably less than 100cycles.
>
>   

The reason for the code movement is that interrupt injection in real 
mode on Intel must be emulated, which means writing into guest memory, 
which means sleeping operations once swap is enabled.  A side benefit is 
removing the lapic calculations from the critical section.

But I still don't understand your object.  The interrupt has to be 
committed sometime.  We move the commit point earlier by the time it 
takes to ->prepare_guest_switch() (normally zero, but sometimes some 
thousand cycles), and kvm_load_guest_fpu() (usually zero as well).  The 
timing is sometimes worse, but there was always a window where a high 
priority interrupt is ignored over low priority interrupts.

[we can try to improve it by using vm86 interrupt redirection which may 
allow event injection using VT instead of writing to the guest stack].

>   
>> high priority interrupt arrives after injection, it will have to wait.
>> The difference is that before this commit, it woke up with the IPI and
>> now it notices with KVM_REQ_INTR.
>>     
>
> When physical IRQ is disabled, the physical IPI will not interrupt 
> pCPU, it get delivered only after we resume to guest.
>
>   

But the effect is the same: the high priority interrupt is delayed.

>> The window grew larger, but not by much typically.
>>     
>
>
> Maybe not much typical, but will frequently happen.
> With this commit, now the window becomes huge since 
> vcpu deschedule may happen :-(
>
>   

If the vcpu is descheduled, then both interrupts are delayed, by much 
more than it takes to process a single one.  If we're descheduled then 
interrupt priority is a very small problem with respect to timing.

> Another serious issue in current code is that due to previous 
> injection, the irq is already consumed, (IRR->ISR). So if there
> are higher priority IRQs arrive later after the previous injection,
> now guest will see 2 IRQs consumed, i.e. 2 ISR bits are set.
>
>   

I don't understand why.  If an event is pending in 
VM_ENTRY_INTR_INFO_FIELD, then we don't call kvm_cpu_get_interrupt() at all.

> I will guess this one is the major problem source if no-kvm-irqchip
> & kvm_irqchip still has difference. And I bet it should cause many
> issues.
>   
Well, I can thing of a workaround by using vm86 interrupt redirection.  
But I'm not convinced it is necessary.

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

  parent reply	other threads:[~2007-10-18  8:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-17  9:17 FW: [kvm-commits] KVM: Move interrupt injection out of interruptdisabled section Dong, Eddie
     [not found] ` <10EA09EFD8728347A513008B6B0DA77A023EF364-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-17 15:42   ` Avi Kivity
     [not found]     ` <47162D74.6010408-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-18  1:10       ` Dong, Eddie
     [not found]         ` <10EA09EFD8728347A513008B6B0DA77A023EF534-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-18  8:59           ` Avi Kivity [this message]
     [not found]             ` <47172084.7020608-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-18 10:16               ` Dong, Eddie
     [not found]                 ` <10EA09EFD8728347A513008B6B0DA77A023EF981-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-18 13:08                   ` Avi Kivity
2007-10-26  8:27               ` Dong, Eddie
     [not found]                 ` <10EA09EFD8728347A513008B6B0DA77A02482B8C-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-26  9:13                   ` Avi Kivity
     [not found]                     ` <4721AFCB.1000502-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-26  9:33                       ` Dong, Eddie
     [not found]                         ` <10EA09EFD8728347A513008B6B0DA77A02482BF7-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-26  9:53                           ` Avi Kivity
     [not found]                             ` <4721B917.3010302-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-26 10:11                               ` Dong, Eddie
     [not found]                                 ` <10EA09EFD8728347A513008B6B0DA77A02482C1C-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-26 10:13                                   ` Avi Kivity
     [not found]                                     ` <4721BDE5.4030308-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-26 10:17                                       ` Dong, Eddie
     [not found]                                         ` <10EA09EFD8728347A513008B6B0DA77A02482C1D-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-10-26 10:22                                           ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47172084.7020608@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=eddie.dong-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox