Skip to contentSkip to conversation

Update event idx if guest has made extra buffers during double check

PATCH Superseded thomas 3 participants 5 messages Jun 13, 2024 – Jun 24, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

thomas

author
#0 lore raw

PATCH 1/1 Update event idx if guest has made extra buffers during double check

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

If guest has made some buffers available during double check, but the total buffer size available is lower than @bufsize, notify the guest with the latest available idx(event idx) seen by the host.

---
 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
Quoted 10 lines · thomas
Fixes 06b12970174 ("virtio-net: fix network stall under load")

If guest has made some buffers available during double check, but the total buffer size available is lower than @bufsize, notify the guest with the latest available idx(event idx) seen by the host.

---
 hw/net/virtio-net.c | 1 +
 1 file changed, 1 insertion(+)

Patch looks good to me, but it misses some other stuff for example:

- the sob tag.
- fixes should be placed above sob tag
- need to cc [email protected]

Thanks

Quoted 16 lines
hw/net/virtio-net.c +1 -1
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;
         }
     }
--

2.39.0

#2 lore raw
In reply to thomas

Thanks for the patch!
Yet something to improve:

subject should list the affected component, and be shorter.

Quoted 1 line · thomas
Fixes 06b12970174 ("virtio-net: fix network stall under load")

this should come at the end. and what exactly does this refer to? did this commit cause a regression of some sort?

Quoted 1 line

If guest has made some buffers available during double check,

what does "double check" refer to?

Quoted 3 lines

but the total buffer size available is lower than @bufsize, notify the guest with the latest available idx(event idx) seen by the host.

which makes sense why? And which changes the correct behavious of what to a new behaviour of what which is better why?

Pls review docs/devel/submitting-a-patch.rst and follow the process there.

Quoted 18 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);
             return 0;
         }
     }
Signature · 1 line
2.39.0
#3 lore raw

hi,

subject should list the affected component, and be shorter.

ok, I will rewrite the subject:
"update the latest available idx seen by the host to event idx"

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

this should come at the end.

I have submitted v2, it's at the end now.

and what exactly does this refer to?

Quoted 1 line

Commit 06b12970174 double-checks whether the guest has made some buffers available after the first check, it will be lucky if the available buffer
size can satisfy the request.

did this commit cause a regression of some sort?

Quoted 1 line

No regression. If the buffer size still can't satisfy the request even if the
guest has made some buffers. this commit doesn't notify the latest shadow_avail_idx seen by the host to the guest. Similar to the first check, if the available buffer is not enough, notify the guest with the updated shadow_avail_idx.

what does "double check" refer to?

Quoted 1 line

it refers to the second nested if condition judgment in virtio_net_has_buffers().

which makes sense why? And which changes the correct behavious of what

Quoted 2 lines

to a new behaviour of what which is better why?

Similar to the first check, if the buffer size still can't satisfy the request, notify the
guest with the updated shadow_avail_idx, it's better than the old one.

Quoted 51 lines · Michael S. Tsirkin

Thanks for the patch!
Yet something to improve:

subject should list the affected component, and be shorter.

Quoted 1 line · thomas
Fixes 06b12970174 ("virtio-net: fix network stall under load")

this should come at the end. and what exactly does this refer to? did this commit cause a regression of some sort?

Quoted 1 line

If guest has made some buffers available during double check,

what does "double check" refer to?

Quoted 3 lines

but the total buffer size available is lower than @bufsize, notify the guest with the latest available idx(event idx) seen by the host.

which makes sense why? And which changes the correct behavious of what to a new behaviour of what which is better why?

Pls review docs/devel/submitting-a-patch.rst and follow the process there.

hw/net/virtio-net.c static int virtio_net_has_buffers(VirtIONetQueue

Quoted 9 lines
---
 hw/net/virtio-net.c | 1 +
 1 file changed, 1 insertion(+)
hw/net/virtio-net.c +0 -0
index 9c7e85caea..23c6c8c898 100644
@@ -1654,6 +1654,7 @@ static int virtio_net_has_buffers(VirtIONetQueue

*q, int bufsize)

Quoted 9 lines
hw/net/virtio-net.c +1 -1
         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;
         }
     }
--

2.39.0

#4 lore raw
Quoted 3 lines · Yang Dongshan

Similar to the first check, if the buffer size still can't satisfy the request, notify the
guest with the updated shadow_avail_idx, it's better than the old one.

So it's an optimization then? Same as any optimization, it should come with measurements showing the performance benefit.

Signature · 1 line
MST