Skip to contentSkip to conversation

vritio-net: Notify the guest with the latest available idx

PATCH Superseded thomas 2 participants 2 messages Jun 24, 2024

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

thomas

author
#0 lore raw

PATCH v3 1/1 vritio-net: Notify the guest with the latest available idx

Patch 06b12970174 ("virtio-net: fix network stall under load") added double-check to test whether the available buffer size can satisfy the request or not, in case the guest has added some buffers to the avail ring simultaneously after the first check.

It will be lucky if the available buffer size becomes okay after the double-check, then the host can send the packet to the guest. If the buffer size still can't satisfy the request, even if the guest has added some buffers, notify the guest with the latest available idx seen by the host, similiar to the action taken by the host after the first check.

Fixes 06b12970174 ("virtio-net: fix network stall under load")
---
 hw/net/virtio-net.c | 1 +
 1 file changed, 1 insertion(+)
hw/net/virtio-net.c +1 -0
index 9c7e85caea..23c6c8c898 100644
@@ -1654,6 +1654,7 @@ static int virtio_net_has_buffers(VirtIONetQueue *q, int bufsize)
         if (virtio_queue_empty(q->rx_vq) ||
             (n->mergeable_rx_bufs &&
              !virtqueue_avail_bytes(q->rx_vq, bufsize, 0))) {
+            virtio_queue_set_notification(q->rx_vq, 1);
             return 0;
         }
     }
Signature · 1 line
2.39.0
#1 lore raw

vritio -> virtio?

When I see a typo straight in the subject I get suspicious about the patch itself.

Quoted 6 lines · thomas

Patch 06b12970174 ("virtio-net: fix network stall under load") added double-check to test whether the available buffer size can satisfy the request or not, in case the guest has added some buffers to the avail ring simultaneously after the first check.

Quoted 6 lines

It will be lucky if the available buffer size becomes okay after the double-check, then the host can send the packet to the guest. If the buffer size still can't satisfy the request, even if the guest has added some buffers, notify the guest with the latest available idx seen by the host, similiar to the action taken by the host after the first check.

The action taken there is to enable host notifications. And this is also what your code does.

Is this some kind of optimization? Bugfix? Can't tell from commit log.

Quoted 2 lines
Fixes 06b12970174 ("virtio-net: fix network stall under load")

Is this spelling with lowercase w in wencheng, intentional?

Quoted 1 line

---

Add changelog here.

hw/net/virtio-net.c static int virtio_net_has_buffers(VirtIONetQueue *q, int bufsize) · line 1657

Quoted 12 lines
 hw/net/virtio-net.c | 1 +
 1 file changed, 1 insertion(+)
hw/net/virtio-net.c +1 -0
index 9c7e85caea..23c6c8c898 100644
@@ -1654,6 +1654,7 @@ static int virtio_net_has_buffers(VirtIONetQueue *q, int bufsize)
         if (virtio_queue_empty(q->rx_vq) ||
             (n->mergeable_rx_bufs &&
              !virtqueue_avail_bytes(q->rx_vq, bufsize, 0))) {
+            virtio_queue_set_notification(q->rx_vq, 1);

I don't really understand what is going on here.
Why is the previous virtio_queue_set_notification(q->rx_vq, 1) insufficient?

Quoted 5 lines
hw/net/virtio-net.c +0 -0
             return 0;
         }
     }
Signature · 1 line
2.39.0