qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] vhost: Don't set vring call if guest notifier is disabled
@ 2025-02-19  1:52 oenhan
  2025-02-20 23:13 ` Michael S. Tsirkin
  0 siblings, 1 reply; 2+ messages in thread
From: oenhan @ 2025-02-19  1:52 UTC (permalink / raw)
  To: mst, sgarzare; +Cc: qemu-devel, qemu-stable, Huaitong Han, Zhiyuan Yuan

From: Huaitong Han <hanht2@chinatelecom.cn>

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.

Fixes: 96a3d98d2c ("vhost: don't set vring call if no vector")

Reported-by: Zhiyuan Yuan <yuanzhiyuan@chinatelecom.cn>
Signed-off-by: Huaitong Han <hanht2@chinatelecom.cn>
---
v2: - add Fixes tag
    - cc qemu-stable@nongnu.org

 hw/virtio/vhost.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 6aa72fd434..d17e7cc6fe 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -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) {
-- 
2.43.5



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

end of thread, other threads:[~2025-02-20 23:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-19  1:52 [PATCH v2] vhost: Don't set vring call if guest notifier is disabled oenhan
2025-02-20 23:13 ` 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).