OSDN Git Service

vhost/vsock: cleanup removing `len` variable
authorStefano Garzarella <sgarzare@redhat.com>
Mon, 22 Nov 2021 16:35:25 +0000 (17:35 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 25 Nov 2021 00:00:28 +0000 (19:00 -0500)
We can increment `total_len` directly and remove `len` since it
is no longer used for vhost_add_used().

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20211122163525.294024-3-sgarzare@redhat.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
drivers/vhost/vsock.c

index 4e3b95a..d6ca1c7 100644 (file)
@@ -511,8 +511,6 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work)
 
        vhost_disable_notify(&vsock->dev, vq);
        do {
-               u32 len;
-
                if (!vhost_vsock_more_replies(vsock)) {
                        /* Stop tx until the device processes already
                         * pending replies.  Leave tx virtqueue
@@ -540,7 +538,7 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work)
                        continue;
                }
 
-               len = pkt->len;
+               total_len += sizeof(pkt->hdr) + pkt->len;
 
                /* Deliver to monitoring devices all received packets */
                virtio_transport_deliver_tap_pkt(pkt);
@@ -553,9 +551,7 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work)
                else
                        virtio_transport_free_pkt(pkt);
 
-               len += sizeof(pkt->hdr);
                vhost_add_used(vq, head, 0);
-               total_len += len;
                added = true;
        } while(likely(!vhost_exceeds_weight(vq, ++pkts, total_len)));