diff options
author | Stefan Hajnoczi | 2020-08-18 16:33:44 +0200 |
---|---|---|
committer | Michael S. Tsirkin | 2020-08-27 14:29:13 +0200 |
commit | 1436f32a84c3fda61d0d80302e24d641d3f3f839 (patch) | |
tree | 7708fd7c4c1c7c01031b9127258cfb8b3d7227c4 /hw/virtio/virtio-pci.h | |
parent | Introduce a new flag for i440fx to disable PCI hotplug on the root bus (diff) | |
download | qemu-1436f32a84c3fda61d0d80302e24d641d3f3f839.tar.gz qemu-1436f32a84c3fda61d0d80302e24d641d3f3f839.tar.xz qemu-1436f32a84c3fda61d0d80302e24d641d3f3f839.zip |
virtio-pci: add virtio_pci_optimal_num_queues() helper
Multi-queue devices achieve the best performance when each vCPU has a
dedicated queue. This ensures that virtqueue used notifications are
handled on the same vCPU that submitted virtqueue buffers. When another
vCPU handles the the notification an IPI will be necessary to wake the
submission vCPU and this incurs a performance overhead.
Provide a helper function that virtio-pci devices will use in later
patches to automatically select the optimal number of queues.
The function handles guests with large numbers of CPUs by limiting the
number of queues to fit within the following constraints:
1. The maximum number of MSI-X vectors.
2. The maximum number of virtqueues.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <20200818143348.310613-4-stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/virtio/virtio-pci.h')
-rw-r--r-- | hw/virtio/virtio-pci.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index e2eaaa9182..91096f0291 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -243,4 +243,13 @@ typedef struct VirtioPCIDeviceTypeInfo { /* Register virtio-pci type(s). @t must be static. */ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t); +/** + * virtio_pci_optimal_num_queues: + * @fixed_queues: number of queues that are always present + * + * Returns: The optimal number of queues for a multi-queue device, excluding + * @fixed_queues. + */ +unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); + #endif |