]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
virtio-net: enable multiqueue by default
authorJason Wang <jasowang@redhat.com>
Fri, 25 Nov 2016 04:37:26 +0000 (12:37 +0800)
committerSi-Wei Liu <si-wei.liu@oracle.com>
Fri, 15 Sep 2017 18:24:21 +0000 (14:24 -0400)
We use single queue even if multiqueue is enabled and let admin to
enable it through ethtool later. This is used to avoid possible
regression (small packet TCP stream transmission). But looks like an
overkill since:

- single queue user can disable multiqueue when launching qemu
- brings extra troubles for the management since it needs extra admin
  tool in guest to enable multiqueue
- multiqueue performs much better than single queue in most of the
  cases

So this patch enables multiqueue by default: if #queues is less than or
equal to #vcpu, enable as much as queue pairs; if #queues is greater
than #vcpu, enable #vcpu queue pairs.

Cc: Hannes Frederic Sowa <hannes@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Neil Horman <nhorman@redhat.com>
Cc: Jeremy Eder <jeder@redhat.com>
Cc: Marko Myllynen <myllynen@redhat.com>
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 4490001029012539937ff02778fe6180613fa949)

Orabug: 26584452

Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
drivers/net/virtio_net.c

index 546b669fbfdd2bcc54ad565bbf83b38c5764e134..0773cf5ef89d1365c08e57f658c0ba481edc8bc3 100644 (file)
@@ -1838,8 +1838,11 @@ static int virtnet_probe(struct virtio_device *vdev)
        if (vi->any_header_sg)
                dev->needed_headroom = vi->hdr_len;
 
-       /* Use single tx/rx queue pair as default */
-       vi->curr_queue_pairs = 1;
+       /* Enable multiqueue by default */
+       if (num_online_cpus() >= max_queue_pairs)
+               vi->curr_queue_pairs = max_queue_pairs;
+       else
+               vi->curr_queue_pairs = num_online_cpus();
        vi->max_queue_pairs = max_queue_pairs;
 
        /* Allocate/initialize the rx/tx queues, and invoke find_vqs */
@@ -1882,6 +1885,8 @@ static int virtnet_probe(struct virtio_device *vdev)
                goto free_recv_bufs;
        }
 
+       virtnet_set_affinity(vi);
+
        /* Assume link up if device can't report link status,
           otherwise get link status from config. */
        if (virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) {