All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: Alex Williamson <alex.williamson@hp.com>,
	kvm@vger.kernel.org, sheng.yang@intel.com
Subject: Re: [PATCH v4] kvm: Use a bitmap for tracking used GSIs
Date: Mon, 18 May 2009 15:19:53 +0300	[thread overview]
Message-ID: <20090518121952.GA14327@redhat.com> (raw)
In-Reply-To: <4A114849.604@redhat.com>

On Mon, May 18, 2009 at 02:36:41PM +0300, Avi Kivity wrote:
> Michael S. Tsirkin wrote:
>> On Sun, May 17, 2009 at 11:47:53PM +0300, Avi Kivity wrote:
>>   
>>> Alex Williamson wrote:
>>>     
>>>> On Wed, 2009-05-13 at 08:33 -0600, Alex Williamson wrote:
>>>>         
>>>>> On Wed, 2009-05-13 at 08:15 -0600, Alex Williamson wrote:
>>>>>             
>>>>>> On Wed, 2009-05-13 at 16:55 +0300, Michael S. Tsirkin wrote:
>>>>>>                 
>>>>>>> Very surprising: I haven't seen any driver disable MSI expect on device
>>>>>>> destructor path. Is this a linux guest?
>>>>>>>                     
>>>>>> Yes, Debian 2.6.26 kernel.  I'll check it it behaves the same on newer
>>>>>> upstream kernels and try to figure out why it's doing it.
>>>>>>                 
>>>>> Updating the guest to 2.6.29 seems to fix the interrupt toggling.  So
>>>>> it's either something in older kernels or something debian introduced,
>>>>> but that seems unlikely.
>>>>>             
>>>> For the curious, this was fixed prior to 2.6.27-rc1 by this:
>>>>
>>>> commit ce6fce4295ba727b36fdc73040e444bd1aae64cd
>>>> Author: Matthew Wilcox
>>>> Date:   Fri Jul 25 15:42:58 2008 -0600
>>>>
>>>>     PCI MSI: Don't disable MSIs if the mask bit isn't supported
>>>>         David Vrabel has a device which generates an interrupt 
>>>> storm on the INTx
>>>>     pin if we disable MSI interrupts altogether.  Masking interrupts is only
>>>>     a performance optimisation, so we can ignore the request to mask the
>>>>     interrupt.
>>>>
>>>> It looks like without the maskbit attribute on MSI, the default way to
>>>> mask an MSI interrupt was to toggle the MSI enable bit.  This was
>>>> introduced in 58e0543e8f355b32f0778a18858b255adb7402ae, so it's lifespan
>>>> was probably 2.6.21 - 2.6.26.
>>>>
>>>>         
>>> On the other hand, if the host device supports this maskbit 
>>> attribute,  we might want to support it.  I'm not sure exactly how 
>>> though.
>>>
>>> If we trap msi entry writes, we're inviting the guest to exit every 
>>> time  it wants to disable interrupts.  If we don't, we're inviting 
>>> spurious  interrupts, which will cause unwanted exits and injections.
>>>     
>>
>> Avi, I think you are mixing up MSI and MSI-X. MSI does not have any tables:
>> all changes go through configuration writes, which AFAIK we always trap.
>> Isn't that right?
>>   
>
> Right.
>
>> On the other hand, in MSI-X mask bit is mandatory, not optional
>> so we'll have to support it for assigned devices at some point.
>>
>> If we are worried about speed of masking/unmasking MSI-X interrupts for
>> assigned devices (older kernels used to mask them, recent kernels leave
>> this to drivers) we will probably need to have MSI-X support in the
>> kernel, and have kernel examine the mask bit before injecting the
>> interrupt, just like real devices do.
>>   
>
> Yes.

Actually, if we do that, we'll need to address a race where a driver
has updated the mask bit in the window after we tested it
and before we inject the interrupt. Not sure how to do this.

> Let's actually quantify this though.  Several times per second  
> doesn't qualify.

Oh, I didn't actually imply that we need to optimize this path.
You seemed worried about the speed of masking the interrupt,
and I commented that to optimize it we'll have to move it
to kernel.

>>> Maybe we ought to let the guest write to the msi tables without   
>>> trapping, and in the injection logic do something like
>>>
>>>    msi_entry = *msi_entry_ptr;
>>>    mb();
>>>    if (msi_entry != msi->last_msi_entry)
>>>         msi_reconfigure();
>>>    if (msi_enabled(msi_entry))
>>>         insert_the_needle();
>>>     
>>
>> I don't really understand why do you need the reconfigure
>> and tracking last msi entry here.
>>   
>
> The msi entry can change the vector and delivery mode, no?  This way we  
> can cache some stuff instead of decoding it each time.  For example, if  
> the entry points at a specific vcpu, we can cache the vcpu pointer,  
> instead of searching for the apic ID.

-- 
MST

  reply	other threads:[~2009-05-18 12:20 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-07 22:22 [PATCH] kvm: Use a bitmap for tracking used GSIs Alex Williamson
2009-05-08 22:31 ` [PATCH v2] " Alex Williamson
2009-05-12 19:39   ` Michael S. Tsirkin
2009-05-12 21:56     ` Alex Williamson
2009-05-12 22:07   ` [PATCH v3] " Alex Williamson
2009-05-13  3:30     ` Yang, Sheng
2009-05-13  3:42       ` Alex Williamson
2009-05-13  4:10         ` Alex Williamson
2009-05-13  4:15           ` Yang, Sheng
2009-05-13  4:41     ` [PATCH v4] " Alex Williamson
2009-05-13  4:58       ` Yang, Sheng
2009-05-13  9:47       ` Avi Kivity
2009-05-13 12:28         ` Alex Williamson
2009-05-13 12:35           ` Avi Kivity
2009-05-13 12:55             ` Alex Williamson
2009-05-13 13:00               ` Avi Kivity
2009-05-13 13:11                 ` Alex Williamson
2009-05-13 13:55                   ` Michael S. Tsirkin
2009-05-13 14:15                     ` Alex Williamson
2009-05-13 14:30                       ` Michael S. Tsirkin
2009-05-13 14:33                       ` Alex Williamson
2009-05-13 23:07                         ` Alex Williamson
2009-05-17 20:47                           ` Avi Kivity
2009-05-18 11:12                             ` Michael S. Tsirkin
2009-05-18 11:36                               ` Avi Kivity
2009-05-18 12:19                                 ` Michael S. Tsirkin [this message]
2009-05-18 12:33                                   ` Avi Kivity
2009-05-18 13:45                                     ` Michael S. Tsirkin
2009-05-18 13:55                                       ` Avi Kivity
2009-05-18 14:40                                         ` Michael S. Tsirkin
2009-05-18 14:46                                           ` Avi Kivity
2009-05-18 15:01                                             ` Michael S. Tsirkin
2009-05-18 15:08                                               ` Avi Kivity
2009-05-13 14:32       ` Michael S. Tsirkin
2009-05-13 15:13       ` [PATCH v5] " Alex Williamson
2009-05-13 16:05         ` Michael S. Tsirkin
2009-05-13 17:13           ` Alex Williamson
2009-05-17 20:51           ` Avi Kivity
2009-05-13 17:28         ` [PATCH v6] " Alex Williamson
2009-05-13 18:46           ` Michael S. Tsirkin
2009-05-17 20:54           ` Avi Kivity
2009-05-18 22:32             ` Alex Williamson
2009-05-19  8:01               ` Avi Kivity
2009-05-19 20:48           ` [PATCH v7] " Alex Williamson
2009-05-20 11:55             ` Avi Kivity
2009-05-13  7:03     ` [PATCH v3] " Michael S. Tsirkin
2009-05-13 12:15       ` Alex Williamson
2009-05-13  7:04     ` Michael S. Tsirkin
2009-05-13 12:19       ` Alex Williamson
2009-05-13 14:25         ` Michael S. Tsirkin
2009-05-17 20:49         ` Avi Kivity
2009-05-11 12:00 ` [PATCH] " Yang, Sheng
2009-05-12 18:45   ` Alex Williamson
2009-05-12 19:06     ` Alex Williamson
2009-05-12 19:10       ` Michael S. Tsirkin
2009-05-12 19:23         ` Alex Williamson

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=20090518121952.GA14327@redhat.com \
    --to=mst@redhat.com \
    --cc=alex.williamson@hp.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=sheng.yang@intel.com \
    /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.