qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] removing on-demand msix vector allocation
@ 2012-12-06  7:59 Michael S. Tsirkin
  2012-12-07  7:37 ` Jan Kiszka
  0 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2012-12-06  7:59 UTC (permalink / raw)
  To: Jan Kiszka, qemu-devel@nongnu.org

I've been looking at handling of msix masking
in qemu. It looks like all of virtio,vfio and
device assignment implemented their own
similar but slightly different thing.
So I am inclined to move this handling to common
code in msix.c, adding irqfd support right there.

While doing this rework, one of the more painful
bits of code to change is the code that dynamically
allocates msix table entries as we inject msi.
If this actually triggers it's going to be
painfully slow as route changes are rcu
write side in kernel.
Since recent kernels support direct injection,
do we care anymore? I think if you run out of
vectors, it's better to simply disable irqchip
than try to limp along changing routes all the time.

Comments?

-- 
MST

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] removing on-demand msix vector allocation
  2012-12-06  7:59 [Qemu-devel] removing on-demand msix vector allocation Michael S. Tsirkin
@ 2012-12-07  7:37 ` Jan Kiszka
  2012-12-10  9:36   ` Michael S. Tsirkin
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kiszka @ 2012-12-07  7:37 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: qemu-devel@nongnu.org

[-- Attachment #1: Type: text/plain, Size: 1186 bytes --]

On 2012-12-06 08:59, Michael S. Tsirkin wrote:
> I've been looking at handling of msix masking
> in qemu. It looks like all of virtio,vfio and
> device assignment implemented their own
> similar but slightly different thing.
> So I am inclined to move this handling to common
> code in msix.c, adding irqfd support right there.
> 
> While doing this rework, one of the more painful
> bits of code to change is the code that dynamically
> allocates msix table entries as we inject msi.
> If this actually triggers it's going to be
> painfully slow as route changes are rcu
> write side in kernel.
> Since recent kernels support direct injection,
> do we care anymore? I think if you run out of
> vectors, it's better to simply disable irqchip
> than try to limp along changing routes all the time.

But how would the logic without dynamic allocation look like? Always
configure a route in the PCI layer if an MSI/MSI-X entry is enabled?
That would also affect emulated devices that don't use irqfd, thus you
would waste routing entries. OTOH, if don't set up such routes, you
cannot support MSI/-X on older x86 kernels without direct vector injection.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 261 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] removing on-demand msix vector allocation
  2012-12-07  7:37 ` Jan Kiszka
@ 2012-12-10  9:36   ` Michael S. Tsirkin
  2012-12-10  9:39     ` Jan Kiszka
  0 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2012-12-10  9:36 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: qemu-devel@nongnu.org

On Fri, Dec 07, 2012 at 08:37:22AM +0100, Jan Kiszka wrote:
> On 2012-12-06 08:59, Michael S. Tsirkin wrote:
> > I've been looking at handling of msix masking
> > in qemu. It looks like all of virtio,vfio and
> > device assignment implemented their own
> > similar but slightly different thing.
> > So I am inclined to move this handling to common
> > code in msix.c, adding irqfd support right there.
> > 
> > While doing this rework, one of the more painful
> > bits of code to change is the code that dynamically
> > allocates msix table entries as we inject msi.
> > If this actually triggers it's going to be
> > painfully slow as route changes are rcu
> > write side in kernel.
> > Since recent kernels support direct injection,
> > do we care anymore? I think if you run out of
> > vectors, it's better to simply disable irqchip
> > than try to limp along changing routes all the time.
> 
> But how would the logic without dynamic allocation look like? Always
> configure a route in the PCI layer if an MSI/MSI-X entry is enabled?
> That would also affect emulated devices that don't use irqfd, thus you
> would waste routing entries.

Yes. 
So we can fail during initialization and ask user to
disable irqchip: at the moment, at least in my testing,
dynamic swap out of MSI entries performs very badly
anyway.

> OTOH, if don't set up such routes, you
> cannot support MSI/-X on older x86 kernels without direct vector injection.
> 
> Jan
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] removing on-demand msix vector allocation
  2012-12-10  9:36   ` Michael S. Tsirkin
@ 2012-12-10  9:39     ` Jan Kiszka
  2012-12-10  9:55       ` Michael S. Tsirkin
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Kiszka @ 2012-12-10  9:39 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: qemu-devel@nongnu.org

[-- Attachment #1: Type: text/plain, Size: 1872 bytes --]

On 2012-12-10 10:36, Michael S. Tsirkin wrote:
> On Fri, Dec 07, 2012 at 08:37:22AM +0100, Jan Kiszka wrote:
>> On 2012-12-06 08:59, Michael S. Tsirkin wrote:
>>> I've been looking at handling of msix masking
>>> in qemu. It looks like all of virtio,vfio and
>>> device assignment implemented their own
>>> similar but slightly different thing.
>>> So I am inclined to move this handling to common
>>> code in msix.c, adding irqfd support right there.
>>>
>>> While doing this rework, one of the more painful
>>> bits of code to change is the code that dynamically
>>> allocates msix table entries as we inject msi.
>>> If this actually triggers it's going to be
>>> painfully slow as route changes are rcu
>>> write side in kernel.
>>> Since recent kernels support direct injection,
>>> do we care anymore? I think if you run out of
>>> vectors, it's better to simply disable irqchip
>>> than try to limp along changing routes all the time.
>>
>> But how would the logic without dynamic allocation look like? Always
>> configure a route in the PCI layer if an MSI/MSI-X entry is enabled?
>> That would also affect emulated devices that don't use irqfd, thus you
>> would waste routing entries.
> 
> Yes. 
> So we can fail during initialization and ask user to
> disable irqchip: at the moment, at least in my testing,
> dynamic swap out of MSI entries performs very badly
> anyway.

That would be a poor approach as it regresses needlessly even over
latest kernels. We only allocate/flush dynamically over older kernels
without direct MSI injections.

What we need is a flag, set e.g. on msi[x]_init, to give the core a hint
if it should allocate static routes for irqfd or if it will be able to
use direct injection later on. Then we can simply do static allocation
unconditionally on kernels without direct injection.

Jan



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 261 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] removing on-demand msix vector allocation
  2012-12-10  9:39     ` Jan Kiszka
@ 2012-12-10  9:55       ` Michael S. Tsirkin
  0 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2012-12-10  9:55 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: qemu-devel@nongnu.org

On Mon, Dec 10, 2012 at 10:39:39AM +0100, Jan Kiszka wrote:
> On 2012-12-10 10:36, Michael S. Tsirkin wrote:
> > On Fri, Dec 07, 2012 at 08:37:22AM +0100, Jan Kiszka wrote:
> >> On 2012-12-06 08:59, Michael S. Tsirkin wrote:
> >>> I've been looking at handling of msix masking
> >>> in qemu. It looks like all of virtio,vfio and
> >>> device assignment implemented their own
> >>> similar but slightly different thing.
> >>> So I am inclined to move this handling to common
> >>> code in msix.c, adding irqfd support right there.
> >>>
> >>> While doing this rework, one of the more painful
> >>> bits of code to change is the code that dynamically
> >>> allocates msix table entries as we inject msi.
> >>> If this actually triggers it's going to be
> >>> painfully slow as route changes are rcu
> >>> write side in kernel.
> >>> Since recent kernels support direct injection,
> >>> do we care anymore? I think if you run out of
> >>> vectors, it's better to simply disable irqchip
> >>> than try to limp along changing routes all the time.
> >>
> >> But how would the logic without dynamic allocation look like? Always
> >> configure a route in the PCI layer if an MSI/MSI-X entry is enabled?
> >> That would also affect emulated devices that don't use irqfd, thus you
> >> would waste routing entries.
> > 
> > Yes. 
> > So we can fail during initialization and ask user to
> > disable irqchip: at the moment, at least in my testing,
> > dynamic swap out of MSI entries performs very badly
> > anyway.
> 
> That would be a poor approach as it regresses needlessly even over
> latest kernels.
> We only allocate/flush dynamically over older kernels
> without direct MSI injections.
> 
> What we need is a flag, set e.g. on msi[x]_init, to give the core a hint
> if it should allocate static routes for irqfd or if it will be able to
> use direct injection later on. Then we can simply do static allocation
> unconditionally on kernels without direct injection.
> 
> Jan
> 
> 

Makes sense.

-- 
MST

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-12-10  9:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-06  7:59 [Qemu-devel] removing on-demand msix vector allocation Michael S. Tsirkin
2012-12-07  7:37 ` Jan Kiszka
2012-12-10  9:36   ` Michael S. Tsirkin
2012-12-10  9:39     ` Jan Kiszka
2012-12-10  9:55       ` Michael S. Tsirkin

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).