--- v4
+++ v1
@@ -9,8 +9,8 @@
16.66% [kernel] [k] detach_buf_split
16.51% [kernel] [k] virtnet_xsk_xmit
14.04% [kernel] [k] virtqueue_add_outbuf
-> 5.18% [kernel] [k] __kmalloc
-> 4.08% [kernel] [k] kfree
+ 5.18% [kernel] [k] __kmalloc
+ 4.08% [kernel] [k] kfree
2.80% [kernel] [k] virtqueue_get_buf_ctx
2.22% [kernel] [k] xsk_tx_peek_desc
2.08% [kernel] [k] memset_erms
@@ -21,10 +21,10 @@
0.53% [kernel] [k] native_apic_mem_write
0.46% [kernel] [k] sg_next
0.43% [kernel] [k] sg_init_table
-> 0.41% [kernel] [k] kmalloc_slab
+ 0.41% [kernel] [k] kmalloc_slab
Compared to not using virtio indirect cache, virtio-net can get a 16%
-performance improvement when using virtio desc cache.
+performance improvement when using indirect desc cache.
In the test case, the CPU where the package is sent has reached 100%.
The following are the PPS in two cases:
@@ -53,53 +53,34 @@
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
- drivers/net/virtio_net.c | 12 +++++++++++-
- 1 file changed, 11 insertions(+), 1 deletion(-)
+ drivers/net/virtio_net.c | 4 ++++
+ 1 file changed, 4 insertions(+)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
-index 9ff2ef9dceca..193c8b38433e 100644
+index 4ad25a8b0870..0ec29cf90d0a 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
-@@ -42,6 +42,9 @@ module_param(csum, bool, 0444);
+@@ -27,9 +27,11 @@ static int napi_weight = NAPI_POLL_WEIGHT;
+ module_param(napi_weight, int, 0444);
+
+ static bool csum = true, gso = true, napi_tx = true;
++static bool virtio_desc_cache = true;
+ module_param(csum, bool, 0444);
module_param(gso, bool, 0444);
module_param(napi_tx, bool, 0644);
++module_param(virtio_desc_cache, bool, 0644);
-+static u32 virtio_desc_cache_threshold = MAX_SKB_FRAGS + 2;
-+module_param(virtio_desc_cache_threshold, uint, 0644);
-+
/* FIXME: MTU in config. */
#define GOOD_PACKET_LEN (ETH_HLEN + VLAN_HLEN + ETH_DATA_LEN)
- #define GOOD_COPY_LEN 128
-@@ -3350,10 +3353,10 @@ static unsigned int mergeable_min_buf_len(struct virtnet_info *vi, struct virtqu
+@@ -3214,6 +3216,8 @@ static int virtnet_probe(struct virtio_device *vdev)
+ vi->curr_queue_pairs = num_online_cpus();
+ vi->max_queue_pairs = max_queue_pairs;
- static int virtnet_find_vqs(struct virtnet_info *vi)
- {
-+ int i, total_vqs, threshold;
- vq_callback_t **callbacks;
- struct virtqueue **vqs;
- int ret = -ENOMEM;
-- int i, total_vqs;
- const char **names;
- bool *ctx;
-
-@@ -3411,10 +3414,17 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
- vi->dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
- }
-
-+ threshold = min_t(u32, virtio_desc_cache_threshold, 2 + MAX_SKB_FRAGS);
++ virtio_use_desc_cache(vdev, virtio_desc_cache);
+
- for (i = 0; i < vi->max_queue_pairs; i++) {
- vi->rq[i].vq = vqs[rxq2vq(i)];
- vi->rq[i].min_buf_len = mergeable_min_buf_len(vi, vi->rq[i].vq);
- vi->sq[i].vq = vqs[txq2vq(i)];
-+
-+ if (!vi->mergeable_rx_bufs && vi->big_packets)
-+ virtqueue_set_desc_cache(vi->rq[i].vq, MAX_SKB_FRAGS + 2);
-+
-+ virtqueue_set_desc_cache(vi->sq[i].vq, threshold);
- }
-
- /* run here: ret == 0. */
+ /* Allocate/initialize the rx/tx queues, and invoke find_vqs */
+ err = init_vqs(vi);
+ if (err)
--
2.31.0