[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V5 15/18] virtio-pci: speedup MSI-X masking and unma
From: |
Jason Wang |
Subject: |
[Qemu-devel] [PATCH V5 15/18] virtio-pci: speedup MSI-X masking and unmasking |
Date: |
Wed, 1 Apr 2015 16:15:09 +0800 |
This patch tries to speed up the MSI-X masking and unmasking through
the mapping between vector and queues. With this patch it will there's
no need to go through all possible virtqueues, which may help to
reduce the time spent when doing MSI-X masking/unmasking a single
vector when more than hundreds or even thousands of virtqueues were
supported.
Tested with 80 queue pairs virito-net-pci by changing the smp affinity
in the background and doing netperf in the same time:
Before the patch:
5711.70 Gbits/sec
After the patch:
6830.98 Gbits/sec
About 19.6% improvements in throughput.
Cc: Michael S. Tsirkin <address@hidden>
Signed-off-by: Jason Wang <address@hidden>
---
hw/virtio/virtio-pci.c | 40 +++++++++++++++++++++-------------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index c38f33f..9a5242a 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -632,28 +632,30 @@ static int virtio_pci_vector_unmask(PCIDevice *dev,
unsigned vector,
{
VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev);
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
- int ret, queue_no;
+ VirtQueue *vq = virtio_vector_first_queue(vdev, vector);
+ int ret, index, unmasked = 0;
- for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) {
- if (!virtio_queue_get_num(vdev, queue_no)) {
+ while (vq) {
+ index = virtio_queue_get_index(vdev, vq);
+ if (!virtio_queue_get_num(vdev, index)) {
break;
}
- if (virtio_queue_vector(vdev, queue_no) != vector) {
- continue;
- }
- ret = virtio_pci_vq_vector_unmask(proxy, queue_no, vector, msg);
+ ret = virtio_pci_vq_vector_unmask(proxy, index, vector, msg);
if (ret < 0) {
goto undo;
}
+ vq = virtio_vector_next_queue(vq);
+ ++unmasked;
}
+
return 0;
undo:
- while (--queue_no >= 0) {
- if (virtio_queue_vector(vdev, queue_no) != vector) {
- continue;
- }
- virtio_pci_vq_vector_mask(proxy, queue_no, vector);
+ vq = virtio_vector_first_queue(vdev, vector);
+ while (vq && --unmasked >= 0) {
+ index = virtio_queue_get_index(vdev, vq);
+ virtio_pci_vq_vector_mask(proxy, index, vector);
+ vq = virtio_vector_next_queue(vq);
}
return ret;
}
@@ -662,16 +664,16 @@ static void virtio_pci_vector_mask(PCIDevice *dev,
unsigned vector)
{
VirtIOPCIProxy *proxy = container_of(dev, VirtIOPCIProxy, pci_dev);
VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
- int queue_no;
+ VirtQueue *vq = virtio_vector_first_queue(vdev, vector);
+ int index;
- for (queue_no = 0; queue_no < proxy->nvqs_with_notifiers; queue_no++) {
- if (!virtio_queue_get_num(vdev, queue_no)) {
+ while (vq) {
+ index = virtio_queue_get_index(vdev, vq);
+ if (!virtio_queue_get_num(vdev, index)) {
break;
}
- if (virtio_queue_vector(vdev, queue_no) != vector) {
- continue;
- }
- virtio_pci_vq_vector_mask(proxy, queue_no, vector);
+ virtio_pci_vq_vector_mask(proxy, index, vector);
+ vq = virtio_vector_next_queue(vq);
}
}
--
2.1.0
- [Qemu-devel] [PATCH V5 07/18] virtio-ccw: using VIRTIO_NO_VECTOR instead of 0 for invalid virtqueue, (continued)
- [Qemu-devel] [PATCH V5 07/18] virtio-ccw: using VIRTIO_NO_VECTOR instead of 0 for invalid virtqueue, Jason Wang, 2015/04/01
- [Qemu-devel] [PATCH V5 08/18] virtio: introduce bus specific queue limit, Jason Wang, 2015/04/01
- [Qemu-devel] [PATCH V5 11/18] virtio-mmio: switch to bus specific queue limit, Jason Wang, 2015/04/01
- [Qemu-devel] [PATCH V5 10/18] virtio-s390: switch to bus specific queue limit, Jason Wang, 2015/04/01
- [Qemu-devel] [PATCH V5 09/18] virtio-ccw: introduce ccw specific queue limit, Jason Wang, 2015/04/01
- [Qemu-devel] [PATCH V5 12/18] virtio-pci: switch to use bus specific queue limit, Jason Wang, 2015/04/01
- [Qemu-devel] [PATCH V5 13/18] virtio: introduce vector to virtqueues mapping, Jason Wang, 2015/04/01
- [Qemu-devel] [PATCH V5 14/18] virtio: introduce virtio_queue_get_index(), Jason Wang, 2015/04/01
- [Qemu-devel] [PATCH V5 15/18] virtio-pci: speedup MSI-X masking and unmasking,
Jason Wang <=
- [Qemu-devel] [PATCH V5 16/18] virtio-pci: increase the maximum number of virtqueues to 513, Jason Wang, 2015/04/01
- Re: [Qemu-devel] [PATCH V5 16/18] virtio-pci: increase the maximum number of virtqueues to 513, Alexander Graf, 2015/04/07
- Re: [Qemu-devel] [PATCH V5 16/18] virtio-pci: increase the maximum number of virtqueues to 513, Luigi Rizzo, 2015/04/07
- Re: [Qemu-devel] [PATCH V5 16/18] virtio-pci: increase the maximum number of virtqueues to 513, Alexander Graf, 2015/04/07
- Re: [Qemu-devel] [PATCH V5 16/18] virtio-pci: increase the maximum number of virtqueues to 513, Jason Wang, 2015/04/08
- Re: [Qemu-devel] [PATCH V5 16/18] virtio-pci: increase the maximum number of virtqueues to 513, Alexander Graf, 2015/04/08
- Re: [Qemu-devel] [PATCH V5 16/18] virtio-pci: increase the maximum number of virtqueues to 513, Jason Wang, 2015/04/08
- Re: [Qemu-devel] [PATCH V5 16/18] virtio-pci: increase the maximum number of virtqueues to 513, Jason Wang, 2015/04/08
- Re: [Qemu-devel] [PATCH V5 16/18] virtio-pci: increase the maximum number of virtqueues to 513, Michael S. Tsirkin, 2015/04/08
- Re: [Qemu-devel] [PATCH V5 16/18] virtio-pci: increase the maximum number of virtqueues to 513, Jason Wang, 2015/04/08