Skip to content

Commit

Permalink
vhost: clean IOTLB cache on vring stop
Browse files Browse the repository at this point in the history
[ upstream commit e7cb7fd ]

Old IOVA cache entries are left when there is a change on virtio driver
in VM. In case that all these old entries have iova addresses lesser
than new iova entries, vhost code will need to iterate all the cache to
find the new ones. In case of just a new iova entry needed for the new
translations, this condition will last forever.

This has been observed in virtio-net to testpmd's vfio-pci driver
transition, reducing the performance from more than 10Mpps to less than
0.07Mpps if the hugepage address was higher than the networking
buffers. Since all new buffers are contained in this new gigantic page,
vhost needs to scan IOTLB_CACHE_SIZE - 1 for each translation at worst.

Fixes: 69c90e9 ("vhost: enable IOMMU support")

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Reported-by: Pei Zhang <pezhang@redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  • Loading branch information
eugpermar authored and cpaelzer committed Nov 30, 2021
1 parent c1e7394 commit 70146f4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/librte_vhost/vhost_user.c
Expand Up @@ -1997,6 +1997,8 @@ vhost_user_get_vring_base(struct virtio_net **pdev,
msg->size = sizeof(msg->payload.state);
msg->fd_num = 0;

vhost_user_iotlb_flush_all(vq);

vring_invalidate(dev, vq);

return RTE_VHOST_MSG_RESULT_REPLY;
Expand Down

0 comments on commit 70146f4

Please sign in to comment.