VDUSE will need to munmap() the IOTLB entry on removal
from the cache, as it performs mmap() before insertion.
This patch introduces a callback that VDUSE layer will
implement to achieve this.
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
---
lib/vhost/iotlb.c | 12 ++++++++++++
lib/vhost/vhost.h | 3 +++
2 files changed, 15 insertions(+)
@@ -25,6 +25,15 @@ struct vhost_iotlb_entry {
#define IOTLB_CACHE_SIZE 2048
+static void
+vhost_user_iotlb_remove_notify(struct virtio_net *dev, struct vhost_iotlb_entry *entry)
+{
+ if (dev->backend_ops->iotlb_remove_notify == NULL)
+ return;
+
+ dev->backend_ops->iotlb_remove_notify(entry->uaddr, entry->uoffset, entry->size);
+}
+
static bool
vhost_user_iotlb_share_page(struct vhost_iotlb_entry *a, struct vhost_iotlb_entry *b)
{
@@ -198,6 +207,7 @@ vhost_user_iotlb_cache_remove_all(struct virtio_net *dev)
vhost_user_iotlb_clear_dump(node, NULL, NULL);
TAILQ_REMOVE(&dev->iotlb_list, node, next);
+ vhost_user_iotlb_remove_notify(dev, node);
vhost_user_iotlb_pool_put(dev, node);
}
@@ -223,6 +233,7 @@ vhost_user_iotlb_cache_random_evict(struct virtio_net *dev)
vhost_user_iotlb_clear_dump(node, prev_node, next_node);
TAILQ_REMOVE(&dev->iotlb_list, node, next);
+ vhost_user_iotlb_remove_notify(dev, node);
vhost_user_iotlb_pool_put(dev, node);
dev->iotlb_cache_nr--;
break;
@@ -314,6 +325,7 @@ vhost_user_iotlb_cache_remove(struct virtio_net *dev, uint64_t iova, uint64_t si
vhost_user_iotlb_clear_dump(node, prev_node, next_node);
TAILQ_REMOVE(&dev->iotlb_list, node, next);
+ vhost_user_iotlb_remove_notify(dev, node);
vhost_user_iotlb_pool_put(dev, node);
dev->iotlb_cache_nr--;
} else {
@@ -89,10 +89,13 @@
for (iter = val; iter < num; iter++)
#endif
+typedef void (*vhost_iotlb_remove_notify)(uint64_t addr, uint64_t off, uint64_t size);
+
/**
* Structure that contains backend-specific ops.
*/
struct vhost_backend_ops {
+ vhost_iotlb_remove_notify iotlb_remove_notify;
};
/**