public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	blauwirbel@gmail.com
Subject: Re: [PATCH v2 0/9] qemu-kvm: Clean up and enhance MSI irqchip support
Date: Wed, 27 Apr 2011 16:49:49 +0300	[thread overview]
Message-ID: <20110427134949.GJ15788@redhat.com> (raw)
In-Reply-To: <4DB81AA4.9060904@siemens.com>

On Wed, Apr 27, 2011 at 03:31:16PM +0200, Jan Kiszka wrote:
> On 2011-04-27 14:12, Avi Kivity wrote:
> > On 04/27/2011 02:21 PM, Jan Kiszka wrote:
> >> On 2011-04-27 11:14, Avi Kivity wrote:
> >>>  On 04/27/2011 12:06 PM, Jan Kiszka wrote:
> >>>>>
> >>>>>   We can simply drop all route entries that are used exclusively in qemu
> >>>>>   (i.e. not bound to an irqfd) and let the cache rebuild itself.
> >>>>
> >>>>  When should they be dropped?
> >>>
> >>>  Whenever we need to allocate a new routing entry, but cannot because it
> >>>  is full.
> >>>
> >>>  def kvm_send_msi_message(addr, val):
> >>>         gsi = route_cache.get((addr, val), None)
> >>>         if gsi is None:
> >>>             expire_volatile_route_cache_entries_if_full()
> >>>             gsi = alloc_gsi_cache_entry()
> >>>             route_cache[(addr, val)] = gsi
> >>>             update_route_cache()
> >>>          kvm_irq_line(gsi, 1)
> >>>          kvm_irq_line(gsi, 0)
> >>>
> >>>  The code would have to be in kvm.c, where it can track whether an entry
> >>>  is volatile or persistent.
> >>
> >> Yeah, what I forgot is the other side of this caching: Looking up the
> >> GSI from the MSI addr/data tuple. That's more complex than the current
> >> O(1) way via device.msitable[vector]. Well, we could use some hash
> >> table. But is it worth it? IMHO only if we could radically simplify the
> >> PCI device hooking as well (HPET is negligible compared to that). But
> >> I'm not yet sure if we can given what vhost needs.
> > 
> > A hash table is indeed overcomplicated for this.
> > 
> > How about a replacement for stl_phys() for the MSI case:
> > 
> > -             stl_phys(timer->fsb >> 32, timer->fsb & 0xffffffff);
> > +           msi_stl_phys(timer->fsb >> 32, timer->fsb & 0xffffffff, 
> > &timer->msi_cache);
> > 
> > msi_stl_phys(target_phys_addr_t addr, uint32_t data, MSICache *cache)

Let's try to use uint64_t for addresses. This is what msi deals with
anyway.

> > {
> >      if (kvm_msi_enabled() && addr & MSI_ADDR_MASK == msi_base_addr) {
> >           if (cache->addr != addr || cache->data != data) {
> >               kvm_update_msi_cache(cache, addr, data);
> >           }
> >           kvm_irq_line(cache->gsi, 1);
> >           kvm_irq_line(cache->gsi, 0);

I think this second ioctl isn't needed on latest kernels.
Was it needed for older ones? Is there a way to detect such?

> >           return;
> >      }
> >      stl_phys(addr, data);
> > }
> 
> I was planning for a MSI short-path anyway. Also for TCG, it's pointless
> to go through lengthy stl_phys if we know it's supposed to be an MSI
> message.

Well, in theory we don't. All MSI does is a store, it could
just go into memory.  For PV (virtio) which is what I coded up msix
originally for, the assumption that it will go into the apic is fine I
think, but I'm a bit less sure with emulated devices.

> > 
> > This bit of code would need to be updated for IOMMU and interrupt 
> > remapping,
> 
> Quite a bit updates required for that anyway.

Yes, I don't think we need to worry about that just yet.

> > but at least it means that devices don't need significant 
> > change for kvm support.  We could also allocate a single gsi for use in 
> > hw/apic.c so hacks like using DMA to generate an MSI will work (will be 
> > slow, though).
> 
> Needs some thoughts, maybe it will work. Though, it's not yet clear to
> me if we can drop the kvm hooks from msi/msix.c and still support
> vhost/dev-assignment this way. Just to keep hpet.c cleaner, I don't
> think it's worth the effort.
> 
> Jan
> 
> -- 
> Siemens AG, Corporate Technology, CT T DE IT 1
> Corporate Competence Center Embedded Linux

  parent reply	other threads:[~2011-04-27 13:50 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-26 13:19 [PATCH v2 0/9] qemu-kvm: Clean up and enhance MSI irqchip support Jan Kiszka
2011-04-26 13:19 ` [PATCH v2 1/9] qemu-kvm: Drop unneeded kvm_irq_routing_entry declaration Jan Kiszka
2011-04-26 13:19 ` [PATCH v2 2/9] qemu-kvm: Rename kvm_msix_message to KVMMsiMessage Jan Kiszka
2011-04-26 13:19 ` [PATCH v2 3/9] qemu-kvm: Refactor MSI core API of KVM Jan Kiszka
2011-04-26 13:19 ` [PATCH v2 4/9] qemu-kvm: Fix and clean up msix vector use/unuse hooks Jan Kiszka
2011-04-26 13:19 ` [PATCH v2 5/9] qemu-kvm: Move gsi bits from kvm_msix_vector_add to kvm_msi_add_message Jan Kiszka
2011-04-26 13:19 ` [PATCH v2 6/9] qemu-kvm: Move entry comparison into kvm_msi_update_message Jan Kiszka
2011-04-26 13:19 ` [PATCH v2 7/9] qemu-kvm: Add in-kernel irqchip support for MSI Jan Kiszka
2011-04-26 13:19 ` [PATCH v2 8/9] qemu-kvm: Refresh MSI settings after vmload Jan Kiszka
2011-04-26 13:19 ` [PATCH v2 9/9] qemu-kvm: hpet: Add MSI support for in-kernel irqchip mode Jan Kiszka
2011-04-26 13:30   ` Michael Tokarev
2011-04-26 13:55     ` Jan Kiszka
2011-04-26 13:56       ` Avi Kivity
2011-04-26 13:58         ` Jan Kiszka
2011-04-26 14:01   ` [PATCH v3 " Jan Kiszka
2011-04-26 16:06     ` Christoph Hellwig
2011-04-26 17:06       ` Jan Kiszka
2011-04-26 17:09         ` Christoph Hellwig
2011-04-27  7:27 ` [PATCH v2 0/9] qemu-kvm: Clean up and enhance MSI irqchip support Avi Kivity
2011-04-27  9:00   ` Jan Kiszka
2011-04-27  9:04     ` Avi Kivity
2011-04-27  9:06       ` Jan Kiszka
2011-04-27  9:14         ` Avi Kivity
2011-04-27 11:21           ` Jan Kiszka
2011-04-27 12:12             ` Avi Kivity
2011-04-27 13:31               ` Jan Kiszka
2011-04-27 13:39                 ` Avi Kivity
2011-04-27 13:54                   ` Jan Kiszka
2011-04-27 14:01                     ` Avi Kivity
2011-04-27 14:11                       ` Michael S. Tsirkin
2011-04-27 14:02                     ` Michael S. Tsirkin
2011-04-27 14:10                       ` Jan Kiszka
2011-04-27 14:14                         ` Michael S. Tsirkin
2011-04-27 14:21                           ` Jan Kiszka
2011-04-27 13:49                 ` Michael S. Tsirkin [this message]
2011-04-27  9:34 ` Avi Kivity
2011-04-27 11:39   ` [PATCH v2 8/9] qemu-kvm: Refresh MSI settings after vmload Jan Kiszka
2011-04-27 12:19     ` Avi Kivity
2011-04-27 14:16     ` Michael S. Tsirkin
2011-04-27 14:28       ` Jan Kiszka
2011-04-27 14:30         ` Michael S. Tsirkin
2011-04-27 14:39           ` Jan Kiszka
2011-04-27 15:09             ` Michael S. Tsirkin
2011-04-27 15:21               ` Jan Kiszka
2011-04-27 16:02                 ` Michael S. Tsirkin
2011-04-27 16:20                   ` Jan Kiszka
2011-04-27 16:26                     ` Michael S. Tsirkin

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=20110427134949.GJ15788@redhat.com \
    --to=mst@redhat.com \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox