[RFC 12/27] vhost: add IOTLB cache entry removal callback
Maxime Coquelin
maxime.coquelin at redhat.com
Thu May 25 13:20:22 CEST 2023
On 5/5/23 07:07, Xia, Chenbo wrote:
> Hi Maxime,
>
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coquelin at redhat.com>
>> Sent: Friday, March 31, 2023 11:43 PM
>> To: dev at dpdk.org; david.marchand at redhat.com; Xia, Chenbo
>> <chenbo.xia at intel.com>; mkp at redhat.com; fbl at redhat.com;
>> jasowang at redhat.com; Liang, Cunming <cunming.liang at intel.com>; Xie, Yongji
>> <xieyongji at bytedance.com>; echaudro at redhat.com; eperezma at redhat.com;
>> amorenoz at redhat.com
>> Cc: Maxime Coquelin <maxime.coquelin at redhat.com>
>> Subject: [RFC 12/27] vhost: add IOTLB cache entry removal callback
>>
>> 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 at redhat.com>
>> ---
>> lib/vhost/iotlb.c | 12 ++++++++++++
>> lib/vhost/vhost.h | 4 ++++
>> 2 files changed, 16 insertions(+)
>>
>> diff --git a/lib/vhost/iotlb.c b/lib/vhost/iotlb.c
>> index 188dfb8e38..86b0be62b4 100644
>> --- a/lib/vhost/iotlb.c
>> +++ b/lib/vhost/iotlb.c
>> @@ -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_set_dump(node);
>>
>> 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 {
>> diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
>> index cc5c707205..2ad26f6951 100644
>> --- a/lib/vhost/vhost.h
>> +++ b/lib/vhost/vhost.h
>> @@ -89,10 +89,14 @@
>> for (iter = val; iter < num; iter++)
>> #endif
>>
>> +struct virtio_net;
>
> Adding this in patch 13 could be better since this patch is not using it.
Right, I changed vhost_iotlb_remove_notify cb prototype but forgot to
remove struct virtio_net afterwards.
Changed in upcoming v2.
Thanks,
Maxime
> Thanks,
> Chenbo
>
>> +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;
>> };
>>
>> /**
>> --
>> 2.39.2
>
More information about the dev
mailing list