kvm.vger.kernel.org archive mirror
 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>,
	Alex Williamson <alex.williamson@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [RFC][PATCH 28/45] qemu-kvm: msix: Drop tracking of used vectors
Date: Tue, 18 Oct 2011 16:01:56 +0200	[thread overview]
Message-ID: <20111018140156.GA4980@redhat.com> (raw)
In-Reply-To: <4E9D831E.100@siemens.com>

On Tue, Oct 18, 2011 at 03:46:06PM +0200, Jan Kiszka wrote:
> On 2011-10-18 15:37, Michael S. Tsirkin wrote:
> > On Tue, Oct 18, 2011 at 03:00:29PM +0200, Jan Kiszka wrote:
> >> On 2011-10-18 14:48, Michael S. Tsirkin wrote:
> >>>> To my understanding, virtio will be the exception as no other device
> >>>> will have a chance to react on resource shortage while sending(!) an MSI
> >>>> message.
> >>>
> >>> Hmm, are you familiar with that spec?
> >>
> >> Not by heart.
> >>
> >>> This is not what virtio does,
> >>> resource shortage is detected during setup.
> >>> This is exactly the problem with lazy registration as you don't
> >>> allocate until it's too late.
> >>
> >> When is that setup phase? Does it actually come after every change to an
> >> MSI vector? I doubt so.
> > 
> > No. During setup, driver requests vectors from the OS, and then tells
> > the device which vector should each VQ use.  It then checks that the
> > assignment was successful. If not, it retries with less vectors.
> > 
> > Other devices can do this during initialization, and signal
> > resource availability to guest using msix vector number field.
> > 
> >> Thus virtio can only estimate the guest usage as
> >> well
> > 
> > At some level, this is fundamental: some guest operations
> > have no failure mode. So we must preallocate
> > some resources to make sure they won't fail.
> 
> We can still track the expected maximum number of active vectors at core
> level, collect them from the KVM layer, and warn if we expect conflicts.
> Anxious MSI users could then refrain from using this feature, others
> might be fine with risking a slow-down on conflicts.

It seems like a nice feature until you have to debug it in the field :).
If you really think it's worthwhile, let's add a 'force' flag so that
advanced users at least can declare that they know what they are doing.

> > 
> >> (a guest may or may not actually write a non-null data into a
> >> vector and unmask it).
> > 
> > Please, forget the non-NULL thing. virtio driver knows exactly
> > how many vectors we use and communicates this info to the device.
> > This is not uncommon at all.
> > 
> >>>
> >>>>>
> >>>>> I actually would not mind preallocating everything upfront which is much
> >>>>> easier.  But with your patch we get a silent failure or a drastic
> >>>>> slowdown which is much more painful IMO.
> >>>>
> >>>> Again: did we already saw that limit? And where does it come from if not
> >>>> from KVM?
> >>>
> >>> It's a hardware limitation of intel APICs. interrupt vector is encoded
> >>> in an 8 bit field in msi address. So you can have at most 256 of these.
> >>
> >> There should be no such limitation with pseudo GSIs we use for MSI
> >> injection. They end up as MSI messages again, so actually 256 (-reserved
> >> vectors) * number-of-cpus (on x86).
> > 
> > This limits which CPUs can get the interrupt though.
> > Linux seems to have a global pool as it wants to be able to freely
> > balance vectors between CPUs. Or, consider a guest with a single CPU :)
> > 
> > Anyway, why argue - there is a limitation, and it's not coming from KVM,
> > right?
> 
> No, our limit we hit with MSI message routing are first of all KVM GSIs,
> and there only pseudo GSIs that do not go to any interrupt controller
> with limited pins.

I see KVM_MAX_IRQ_ROUTES 1024
This is > 256 so KVM does not seem to be the problem.

> That could easily be lifted in the kernel if we run
> into shortages in practice.

What I was saying is that resources are limited even without kvm.

> > 
> >>>
> >>>>>
> >>>>>> That's also why we do those data == 0
> >>>>>> checks to skip used but unconfigured vectors.
> >>>>>>
> >>>>>> Jan
> >>>>>
> >>>>> These checks work more or less by luck BTW. It's
> >>>>> a hack which I hope lazy allocation will replace.
> >>>>
> >>>> The check is still valid (for x86) when we have to use static routes
> >>>> (device assignment, vhost).
> >>>
> >>> It's not valid at all - we are just lucky that linux and
> >>> windows guests seem to zero out the vector when it's not in use.
> >>> They do not have to do that.
> >>
> >> It is valid as it is just an optimization. If an unused vector has a
> >> non-null data field, we just redundantly register a route where we do
> >> not actually have to.
> > 
> > Well, the only reason we even have this code is because
> > it was claimed that some devices declare support for a huge number
> > of vectors which then go unused. So if the guest does not
> > do this we'll run out of vectors ...
> > 
> >> But we do need to be prepared
> > 
> > And ATM, we aren't, and probably can't be without kernel
> > changes, right?
> > 
> >> for potentially
> >> arriving messages on that virtual GSI, either via irqfd or kvm device
> >> assignment.
> >>
> >> Jan
> > 
> > Why irqfd?  Device assignment is ATM the only place where we use these
> > ugly hacks.
> 
> vfio will use irqfds. And that virtio is partly out of the picture is
> only because we know much more about virtio internals (specifically:
> "will not advertise more vectors than guests will want to use").
> 
> Jan
> 
> -- 
> Siemens AG, Corporate Technology, CT T DE IT 1
> Corporate Competence Center Embedded Linux

  reply	other threads:[~2011-10-18 14:01 UTC|newest]

Thread overview: 144+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-17  9:27 [RFC][PATCH 00/45] qemu-kvm: MSI layer rework for in-kernel irqchip support Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 01/45] msi: Guard msi/msix_write_config with msi_present Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 02/45] msi: Guard msi_reset " Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 03/45] msi: Use msi/msix_present more consistently Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 04/45] msi: Invoke msi/msix_reset from PCI core Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 05/45] msi: Invoke msi/msix_write_config " Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 06/45] msix: Prevent bogus mask updates on MMIO accesses Jan Kiszka
2011-10-17 11:10   ` Michael S. Tsirkin
2011-10-17 11:23     ` Jan Kiszka
2011-10-17 11:57       ` Michael S. Tsirkin
2011-10-17 12:07         ` Jan Kiszka
2011-10-17 12:50           ` Michael S. Tsirkin
2011-10-17 19:11             ` Jan Kiszka
2011-10-17 19:43               ` Michael S. Tsirkin
2011-10-17  9:27 ` [RFC][PATCH 07/45] msi: Generalize msix_supported to msi_supported Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 08/45] Introduce MSIMessage structure Jan Kiszka
2011-10-17 11:46   ` Michael S. Tsirkin
2011-10-17 11:51     ` Jan Kiszka
2011-10-17 12:04       ` Michael S. Tsirkin
2011-10-17 12:09         ` Jan Kiszka
2011-10-17 13:01           ` Michael S. Tsirkin
2011-10-17 19:14             ` Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 09/45] msi: Factor out msi_message_from_vector Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 10/45] msix: Factor out msix_message_from_vector Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 11/45] msi: Factor out delivery hook Jan Kiszka
2011-10-17 10:56   ` Avi Kivity
2011-10-17 11:15     ` Jan Kiszka
2011-10-17 11:22       ` Avi Kivity
2011-10-17 11:29         ` Jan Kiszka
2011-10-17 12:14           ` Avi Kivity
2011-10-17 18:59             ` Jan Kiszka
2011-10-17 13:41       ` Michael S. Tsirkin
2011-10-17 13:41         ` Avi Kivity
2011-10-17 13:48           ` Michael S. Tsirkin
2011-10-17 19:18             ` Jan Kiszka
2011-10-17 13:43   ` Michael S. Tsirkin
2011-10-17 19:15     ` Jan Kiszka
2011-10-18 12:05       ` Michael S. Tsirkin
2011-10-18 12:23         ` Jan Kiszka
2011-10-18 12:38           ` Michael S. Tsirkin
2011-10-18 12:41             ` Jan Kiszka
2011-10-18 12:44             ` malc
2011-10-18 12:49               ` Michael S. Tsirkin
2011-10-17  9:27 ` [RFC][PATCH 12/45] msi: Introduce MSIRoutingCache Jan Kiszka
2011-10-17 11:06   ` Avi Kivity
2011-10-17 11:19     ` Jan Kiszka
2011-10-17 11:25       ` Avi Kivity
2011-10-17 11:31         ` Jan Kiszka
2011-10-17 12:17           ` Avi Kivity
2011-10-17 15:37       ` Michael S. Tsirkin
2011-10-17 19:19         ` Jan Kiszka
2011-10-18 12:17           ` Michael S. Tsirkin
2011-10-18 12:26             ` Jan Kiszka
2011-10-17 15:43   ` Michael S. Tsirkin
2011-10-17 19:23     ` Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 13/45] hpet: Use msi_deliver Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 14/45] qemu-kvm: Drop useless kvm_clear_gsi_routes Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 15/45] qemu-kvm: Drop unused kvm_del_irq_route Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 16/45] qemu-kvm: Use MSIMessage and MSIRoutingCache Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 17/45] qemu-kvm: Track MSIRoutingCache in KVM routing table Jan Kiszka
2011-10-17 11:13   ` Avi Kivity
2011-10-17 11:25     ` Jan Kiszka
2011-10-17 12:15       ` Avi Kivity
2011-10-17  9:27 ` [RFC][PATCH 18/45] qemu-kvm: Hook into MSI delivery at APIC level Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 19/45] qemu-kvm: Factor out kvm_msi_irqfd_set Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 20/45] qemu-kvm: msix: Only invoke msix_handle_mask_update on changes Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 21/45] qemu-kvm: msix: Don't fire notifier spuriously on set/unset Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 22/45] qemu-kvm: msix: Fire mask notifier on global mask changes Jan Kiszka
2011-10-17 12:16   ` Michael S. Tsirkin
2011-10-17 19:00     ` Jan Kiszka
2011-10-18 12:40       ` Michael S. Tsirkin
2011-10-18 12:45         ` Jan Kiszka
2011-10-18 12:57           ` Michael S. Tsirkin
2011-10-17  9:27 ` [RFC][PATCH 23/45] qemu-kvm: Rework MSI-X mask notifier to generic MSI config notifiers Jan Kiszka
2011-10-17 11:40   ` Michael S. Tsirkin
2011-10-17 11:45     ` Jan Kiszka
2011-10-17 12:39       ` Michael S. Tsirkin
2011-10-17 19:08         ` Jan Kiszka
2011-10-18 13:46           ` Michael S. Tsirkin
2011-10-18 13:49             ` Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 24/45] qemu-kvm: msix: Don't handle mask updated while disabled Jan Kiszka
2011-10-17  9:27 ` [RFC][PATCH 25/45] qemu-kvm: Update MSI cache on kvm_msi_irqfd_set Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 26/45] qemu-kvm: Use g_realloc for irq_routes extension Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 27/45] qemu-kvm: Lazily update MSI caches Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 28/45] qemu-kvm: msix: Drop tracking of used vectors Jan Kiszka
2011-10-17 15:48   ` Michael S. Tsirkin
2011-10-17 19:28     ` Jan Kiszka
2011-10-18 11:58       ` Michael S. Tsirkin
2011-10-18 12:08         ` Jan Kiszka
2011-10-18 12:33           ` Michael S. Tsirkin
2011-10-18 12:38             ` Jan Kiszka
2011-10-18 12:48               ` Michael S. Tsirkin
2011-10-18 13:00                 ` Jan Kiszka
2011-10-18 13:37                   ` Michael S. Tsirkin
2011-10-18 13:46                     ` Jan Kiszka
2011-10-18 14:01                       ` Michael S. Tsirkin [this message]
2011-10-18 14:08                         ` Jan Kiszka
2011-10-18 15:08                           ` Michael S. Tsirkin
2011-10-18 15:22                             ` Jan Kiszka
2011-10-18 15:55                               ` Jan Kiszka
2011-10-18 17:06                                 ` Michael S. Tsirkin
2011-10-18 18:24                                   ` Jan Kiszka
2011-10-18 18:40                                     ` Michael S. Tsirkin
2011-10-18 19:37                                       ` Jan Kiszka
2011-10-18 21:40                                         ` Michael S. Tsirkin
2011-10-18 22:13                                           ` Jan Kiszka
2011-10-19  0:56                                             ` Michael S. Tsirkin
2011-10-19  6:41                                               ` Jan Kiszka
2011-10-19  9:03                                                 ` Michael S. Tsirkin
2011-10-19 11:17                                                   ` Jan Kiszka
2011-10-20 22:02                                                     ` Michael S. Tsirkin
2011-10-21  7:09                                                       ` Jan Kiszka
2011-10-21  7:54                                                         ` Michael S. Tsirkin
2011-10-21  9:27                                                           ` Jan Kiszka
2011-10-21 10:57                                                             ` Michael S. Tsirkin
2011-10-18 18:26                                   ` Jan Kiszka
2011-10-18 15:56                               ` Michael S. Tsirkin
2011-10-18 15:58                                 ` Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 29/45] pci-assign: Drop kvm_assigned_irq::host_irq initialization Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 30/45] pci-assign: Rename assign_irq to assign_intx Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 31/45] qemu-kvm: Refactor kvm_deassign_irq to kvm_device_irq_deassign Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 32/45] pci-assign: Factor out deassign_irq Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 33/45] qemu-kvm: Factor out kvm_device_intx_assign Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 34/45] qemu-kvm: Factor out kvm_device_msi_assign Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 35/45] pci-assign: Polish assigned_dev_update_msix_mmio Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 36/45] qemu-kvm: Factor out kvm_device_msix_* services Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 37/45] qemu-kvm: Clean up irqrouting API Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 38/45] msi: Implement config notifiers for legacy MSI Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 39/45] pci-assign: Use generic MSI support Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 40/45] qemu-kvm: msix: Drop check for preexisting cap from msix_add_config Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 41/45] msix: Drop unused msix_bar_size Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 42/45] msix: Introduce msix_init_simple Jan Kiszka
2011-10-17 11:22   ` Michael S. Tsirkin
2011-10-17 11:27     ` Jan Kiszka
2011-10-17 14:28       ` Michael S. Tsirkin
2011-10-17 19:21         ` Jan Kiszka
2011-10-18 10:52           ` Michael S. Tsirkin
2011-10-18 11:02             ` Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 43/45] msix: Allow to customize capability on init Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 44/45] pci-assign: Use generic MSI-X support Jan Kiszka
2011-10-17  9:28 ` [RFC][PATCH 45/45] pci-assign: Fix coding style issues Jan Kiszka
2011-10-17 12:18 ` [RFC][PATCH 00/45] qemu-kvm: MSI layer rework for in-kernel irqchip support Avi Kivity
2011-10-17 15:57 ` Michael S. Tsirkin
2011-10-17 19:35   ` Jan Kiszka

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=20111018140156.GA4980@redhat.com \
    --to=mst@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=avi@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).