Skip to contentSkip to conversation

VSOCK: batch sending rx buffer to increase bandwidth

PATCH In review jiangyiwen 2 participants 5 messages Dec 12, 2018 – Dec 14, 2018

Subsystems (6)
lore
Share & tools
lore

jiangyiwen

author
#0 lore raw

PATCH v2 5/5 VSOCK: batch sending rx buffer to increase bandwidth

Batch sending rx buffer can improve total bandwidth.

---
 drivers/vhost/vsock.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
drivers/vhost/vsock.c +17 -7
index 9600133..a4bf0a1 100644
@@ -151,9 +151,11 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
 			    struct vhost_virtqueue *vq)
 {
 	struct vhost_virtqueue *tx_vq = &vsock->vqs[VSOCK_VQ_TX];
-	bool added = false;
 	bool restart_tx = false;
 	size_t vsock_hlen;
+	int batch_count = 0;
+
+#define VHOST_VSOCK_BATCH 16
 
 	mutex_lock(&vq->mutex);
 
@@ -194,8 +196,9 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
 		list_del_init(&pkt->list);
 		spin_unlock_bh(&vsock->send_pkt_list_lock);
 
-		headcount = get_rx_bufs(vq, vq->heads, vsock_hlen + pkt->len,
-				&in, likely(vsock->mergeable) ? UIO_MAXIOV : 1);
+		headcount = get_rx_bufs(vq, vq->heads + batch_count,
+				vsock_hlen + pkt->len, &in,
+				likely(vsock->mergeable) ? UIO_MAXIOV : 1);
 		if (headcount <= 0) {
 			spin_lock_bh(&vsock->send_pkt_list_lock);
 			list_add(&pkt->list, &vsock->send_pkt_list);
@@ -238,8 +241,12 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
 			remain_len -= tmp_len;
 		}
 
-		vhost_add_used_n(vq, vq->heads, headcount);
-		added = true;
+		batch_count += headcount;
+		if (batch_count > VHOST_VSOCK_BATCH) {
+			vhost_add_used_and_signal_n(&vsock->dev, vq,
+					vq->heads, batch_count);
+			batch_count = 0;
+		}
 
 		if (pkt->reply) {
 			int val;
@@ -258,8 +265,11 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
 
 		virtio_transport_free_pkt(pkt);
 	}
-	if (added)
-		vhost_signal(&vsock->dev, vq);
+
+	if (batch_count) {
+		vhost_add_used_and_signal_n(&vsock->dev, vq,
+				vq->heads, batch_count);
+	}
 
 out:
 	mutex_unlock(&vq->mutex);
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 4 lines · jiangyiwen

Batch sending rx buffer can improve total bandwidth.

---

Please send patches with git-send-email --thread --no-chain-reply-to so that your patch series email thread looks like this:

* [PATCH 00/NN] My feature

  +-- [PATCH 01/NN] First patch
  +-- [PATCH 02/NN] Second patch

.
.
.
+-- [PATCH NN/NN] Last patch

This way it's much easier to view the entire series. At the moment you are sending each patch as an independent email and there is no relationship between the emails.

Thanks,
Stefan

author
#2 lore raw
Quoted 17 lines · Stefan Hajnoczi
Quoted 4 lines · jiangyiwen

Batch sending rx buffer can improve total bandwidth.

---

Please send patches with git-send-email --thread --no-chain-reply-to so that your patch series email thread looks like this:

* [PATCH 00/NN] My feature

  +-- [PATCH 01/NN] First patch
  +-- [PATCH 02/NN] Second patch

.
.
.
+-- [PATCH NN/NN] Last patch

Quoted 7 lines

This way it's much easier to view the entire series. At the moment you are sending each patch as an independent email and there is no relationship between the emails.

Thanks,
Stefan

Thanks Stefan, I have not send a series of patches before, and I will use email thread form in the later version.

Thanks again,
Yiwen.

author
#3 lore raw
In reply to Stefan Hajnoczi
Quoted 17 lines · Stefan Hajnoczi
Quoted 4 lines · jiangyiwen

Batch sending rx buffer can improve total bandwidth.

---

Please send patches with git-send-email --thread --no-chain-reply-to so that your patch series email thread looks like this:

* [PATCH 00/NN] My feature

  +-- [PATCH 01/NN] First patch
  +-- [PATCH 02/NN] Second patch

.
.
.
+-- [PATCH NN/NN] Last patch

Quoted 7 lines

This way it's much easier to view the entire series. At the moment you are sending each patch as an independent email and there is no relationship between the emails.

Thanks,
Stefan

Thanks Stefan, I have not send a series of patches before, and I will use email thread form in the later version.

Thanks again,
Yiwen.

maintainer
#4 lore raw
In reply to jiangyiwen
Quoted 4 lines · jiangyiwen

Batch sending rx buffer can improve total bandwidth.

---

Please send patches with git-send-email --thread --no-chain-reply-to so that your patch series email thread looks like this:

* [PATCH 00/NN] My feature

  +-- [PATCH 01/NN] First patch
  +-- [PATCH 02/NN] Second patch

.
.
.
+-- [PATCH NN/NN] Last patch

This way it's much easier to view the entire series. At the moment you are sending each patch as an independent email and there is no relationship between the emails.

Thanks,
Stefan

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization