vhost: Don't set vring call if guest notifier is disabled
PATCH v2 1/1 vhost: Don't set vring call if guest notifier is disabled
From: Huaitong Han <[email protected]>
The vring call fd is set even when the guest does not use MSIX (e.g., virtio PMD). This results in unnecessary CPU overhead for handling virtio interrupts. The previous patch only optimized the condition when query_queue_notifier was enabled and the vector was unset. However, if query_queue_notifier is disabled, the vring call FD should also be unset to avoid this inefficiency.
---
v2: - add Fixes tag
- cc [email protected]
hw/virtio/vhost.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/virtio/vhost.c +2 -2
@@ -1342,8 +1342,8 @@ int vhost_virtqueue_start(struct vhost_dev *dev, }if (k->query_guest_notifiers && - k->query_guest_notifiers (qbus->parent) && -virtio_queue_vector (vdev, idx) ==VIRTIO_NO_VECTOR ) { + (!k->query_guest_notifiers (qbus->parent) || +virtio_queue_vector (vdev, idx) ==VIRTIO_NO_VECTOR )) { file.fd =-1 ; r = dev->vhost_ops->vhost_set_vring_call (dev, &file);if (r) {
Signature · 1 line
2.43.5
Quoted 8 lines · On Wed, Feb 19, 2025 at 09:52:35AM +0800, [email protected] wrote:
From: Huaitong Han <[email protected]>
The vring call fd is set even when the guest does not use MSIX (e.g., virtio PMD). This results in unnecessary CPU overhead for handling virtio interrupts. The previous patch only optimized the condition when
query_queue_notifierwas enabled and the vector was unset. However, ifquery_queue_notifieris disabled, the vring call FD should also be unset to avoid this inefficiency.
Quoted 4 lines
Fixes 96a3d98d2c ("vhost: don't set vring call if no vector")Reported-by Zhiyuan Yuan <[email protected]>Signed-off-by Huaitong Han <[email protected]>
Fails make check:
https://gitlab.com/mstredhat/qemu/-/jobs/9201935243
how was this tested? Pls include data on testing in the commit log.
Quoted 24 lines
---
v2: - add Fixes tag
- cc [email protected]hw/virtio/vhost.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/virtio/vhost.c +2
-2@@ -1342,8 +1342,8 @@ int vhost_virtqueue_start(struct vhost_dev *dev, }if (k->query_guest_notifiers && - k->query_guest_notifiers (qbus->parent) && -virtio_queue_vector (vdev, idx) ==VIRTIO_NO_VECTOR ) { + (!k->query_guest_notifiers (qbus->parent) || +virtio_queue_vector (vdev, idx) ==VIRTIO_NO_VECTOR )) { file.fd =-1 ; r = dev->vhost_ops->vhost_set_vring_call (dev, &file);if (r) {Signature · 1 line
2.43.5