Skip to contentSkip to conversation

vsock/virtio: a better comment on credit update

PATCH Applied Michael S. Tsirkin 3 participants 5 messages Sep 3, 2019 – Sep 5, 2019

Subsystems (6)
lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

PATCH 1/1 vsock/virtio: a better comment on credit update

The comment we have is just repeating what the code does. Include the *reason* for the condition instead.

Cc Stefano Garzarella <[email protected]>
---
 net/vmw_vsock/virtio_transport_common.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
net/vmw_vsock/virtio_transport_common.c +7 -2
index 94cc0fa3e848..5bb70c692b1e 100644
@@ -307,8 +307,13 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk,
 
 	spin_unlock_bh(&vvs->rx_lock);
 
-	/* We send a credit update only when the space available seen
-	 * by the transmitter is less than VIRTIO_VSOCK_MAX_PKT_BUF_SIZE
+	/* To reduce the number of credit update messages,
+	 * don't update credits as long as lots of space is available.
+	 * Note: the limit chosen here is arbitrary. Setting the limit
+	 * too high causes extra messages. Too low causes transmitter
+	 * stalls. As stalls are in theory more expensive than extra
+	 * messages, we set the limit to a high value. TODO: experiment
+	 * with different values.
 	 */
 	if (free_space < VIRTIO_VSOCK_MAX_PKT_BUF_SIZE) {
 		virtio_transport_send_credit_update(vsk,
Signature · 1 line
MST
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Michael S. Tsirkin

The comment we have is just repeating what the code does. Include the *reason* for the condition instead.

Cc Stefano Garzarella <[email protected]>
---
 net/vmw_vsock/virtio_transport_common.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
net/vmw_vsock/virtio_transport_common.c +0 -2
index 94cc0fa3e848..5bb70c692b1e 100644
@@ -307,8 +307,13 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk,
 
 	spin_unlock_bh(&vvs->rx_lock);
 
-	/* We send a credit update only when the space available seen
-	 * by the transmitter is less than VIRTIO_VSOCK_MAX_PKT_BUF_SIZE

net/vmw_vsock/virtio_transport_common.c virtio_transport_stream_do_dequeue(struct vsock_sock *vsk, · line 319

Quoted 10 lines
net/vmw_vsock/virtio_transport_common.c +7 -0
+	/* To reduce the number of credit update messages,
+	 * don't update credits as long as lots of space is available.
+	 * Note: the limit chosen here is arbitrary. Setting the limit
+	 * too high causes extra messages. Too low causes transmitter
+	 * stalls. As stalls are in theory more expensive than extra
+	 * messages, we set the limit to a high value. TODO: experiment
+	 * with different values.
 	 */
 	if (free_space < VIRTIO_VSOCK_MAX_PKT_BUF_SIZE) {
 		virtio_transport_send_credit_update(vsk,
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Michael S. Tsirkin
Quoted 19 lines · Michael S. Tsirkin

The comment we have is just repeating what the code does. Include the *reason* for the condition instead.

Cc Stefano Garzarella <[email protected]>
---
 net/vmw_vsock/virtio_transport_common.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
net/vmw_vsock/virtio_transport_common.c +0 -2
index 94cc0fa3e848..5bb70c692b1e 100644
@@ -307,8 +307,13 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk,
 
 	spin_unlock_bh(&vvs->rx_lock);
 
-	/* We send a credit update only when the space available seen
-	 * by the transmitter is less than VIRTIO_VSOCK_MAX_PKT_BUF_SIZE

net/vmw_vsock/virtio_transport_common.c virtio_transport_stream_do_dequeue(struct vsock_sock *vsk, · line 319

Quoted 10 lines
net/vmw_vsock/virtio_transport_common.c +7 -0
+	/* To reduce the number of credit update messages,
+	 * don't update credits as long as lots of space is available.
+	 * Note: the limit chosen here is arbitrary. Setting the limit
+	 * too high causes extra messages. Too low causes transmitter
+	 * stalls. As stalls are in theory more expensive than extra
+	 * messages, we set the limit to a high value. TODO: experiment
+	 * with different values.
 	 */
 	if (free_space < VIRTIO_VSOCK_MAX_PKT_BUF_SIZE) {
 		virtio_transport_send_credit_update(vsk,