summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXuan Zhuo <xuanzhuo@linux.alibaba.com>2024-10-29 16:46:14 +0800
committerPaolo Abeni <pabeni@redhat.com>2024-11-05 11:37:40 +0100
commit47008bb51c3e11c187dacc17af334bdca97c2dca (patch)
treea02b82d3a2ddb7199aad0efeb4f1ecafe5c439ac
parenta33f3df850750216f432b637a5020ad6a740cac1 (diff)
virtio_net: enable premapped mode for merge and small by default
Currently, the virtio core will perform a dma operation for each buffer. Although, the same page may be operated multiple times. In premapped mod, we can perform only one dma operation for the pages of the alloc frag. This is beneficial for the iommu device. kernel command line: intel_iommu=on iommu.passthrough=0 | strict=0 | strict=1 Before | 775496pps | 428614pps After | 1109316pps | 742853pps In the 6.11, we disabled this feature because a regress [1]. Now, we fix the problem and re-enable it. [1]: http://lore.kernel.org/all/8b20cc28-45a9-4643-8e87-ba164a540c0a@oracle.com Tested-by: Darren Kenny <darren.kenny@oracle.com> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
-rw-r--r--drivers/net/virtio_net.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index b82f6b8a8231..befc30b3abb1 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -6107,6 +6107,17 @@ err_ctrl:
return -ENOMEM;
}
+static void virtnet_rq_set_premapped(struct virtnet_info *vi)
+{
+ int i;
+
+ for (i = 0; i < vi->max_queue_pairs; i++) {
+ /* error should never happen */
+ BUG_ON(virtqueue_set_dma_premapped(vi->rq[i].vq));
+ vi->rq[i].do_dma = true;
+ }
+}
+
static int init_vqs(struct virtnet_info *vi)
{
int ret;
@@ -6120,6 +6131,10 @@ static int init_vqs(struct virtnet_info *vi)
if (ret)
goto err_free;
+ /* disable for big mode */
+ if (!vi->big_packets || vi->mergeable_rx_bufs)
+ virtnet_rq_set_premapped(vi);
+
cpus_read_lock();
virtnet_set_affinity(vi);
cpus_read_unlock();