vhost-net: initialize zcopy packet counters
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 3 Dec 2012 07:31:51 +0000 (07:31 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 3 Dec 2012 18:42:17 +0000 (13:42 -0500)
These packet counters are used to drive the zercopy
selection heuristic so nothing too bad happens if they are off a bit -
and they are also reset once in a while.
But it's cleaner to clear them when backend is set so that
we start in a known state.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/vhost/net.c

index 67898fa9c4477f053ddaaadc05431ae77b918b7a..ff6c91995c96ca25389e1249d80cb42e2402c6de 100644 (file)
@@ -823,6 +823,9 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
                r = vhost_init_used(vq);
                if (r)
                        goto err_vq;
+
+               n->tx_packets = 0;
+               n->tx_zcopy_err = 0;
        }
 
        mutex_unlock(&vq->mutex);