All of lore.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 15:08:19 +0200	[thread overview]
Message-ID: <47175AC3.3070405@qumranet.com> (raw)
In-Reply-To: <10EA09EFD8728347A513008B6B0DA77A023EF981-wq7ZOvIWXbNpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>

Dong, Eddie wrote:
>
>> 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.
>>     
>
> Yes even in rare native when 2 irqs arrives at almost same time.
> But now we have frequent happenings. Guest frequently see
> higher irq pending. Let us keep an eye to see if it will hurt something.
>
> Then probably need this patch?
>
> diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
> index aab465d..46ad3b7 100644
> --- a/drivers/kvm/kvm_main.c
> +++ b/drivers/kvm/kvm_main.c
> @@ -2165,6 +2165,7 @@ again:
>         if (unlikely(r))
>                 goto out;
>
> +       vcpu->guest_mode = 1;
>         kvm_inject_pending_timer_irqs(vcpu);
>         clear_bit(KVM_REQ_INTR, &vcpu->requests);
>         if (irqchip_in_kernel(vcpu->kvm))
> @@ -2183,6 +2184,7 @@ again:
>                 local_irq_enable();
>                 preempt_enable();
>                 r = -EINTR;
> +               vcpu->guest_mode = 0;
>                 kvm_run->exit_reason = KVM_EXIT_INTR;
>                 ++vcpu->stat.signal_exits;
>                 goto out;
> @@ -2192,6 +2194,7 @@ again:
>                 if (test_and_clear_bit(KVM_REQ_TLB_FLUSH,
> &vcpu->requests))
>                         kvm_x86_ops->tlb_flush(vcpu);
>                 if (test_bit(KVM_REQ_INTR, &vcpu->requests)) {
> +                       vcpu->guest_mode = 0;
>                         local_irq_enable();
>                         preempt_enable();
>                         r = 1;
> @@ -2199,7 +2202,6 @@ again:
>                 }
>         }
>
> -       vcpu->guest_mode = 1;
>         kvm_guest_enter();
>
>         kvm_x86_ops->run(vcpu, kvm_run);
>
>   

I don't see why this is needed.  The interrupt code will 
set_bit(KVM_REQ_INTR) even if the vcpu is not in guest mode.


>   
>> [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].
>>     
>
> :) Love this much more personaly, or lock pages.
>
>   

We could lock the pages like this:

- do the interrupt injection
    - if a real mode interrupt, abort, and set a flag requesting to lock 
the guest pages
        - exit the critical section
        - notice the flag is set, lock guest stack
        - retry
    - otherwise, proceed with injection

but using vm86 interrupt redirection is better.


>>> 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.
>>
>>     
> This is for protect mode. real mode is not setting this one,
> and thus double consumed.
>
>   

Good point.  That is also fixed by using vm86 interrupt redirection.  
I'll read some more about it.

> But this is fixable with other additional logic. My point is that
> we may see more potential issues now :-(
>
>
>   

You're right.  Well, that's the price of progress (swapping).

-- 
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 13:08 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
     [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 [this message]
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=47175AC3.3070405@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.