[RFC,20/27] vhost: add VDUSE callback for IOTLB entry removal

Message ID 20230331154259.1447831-21-maxime.coquelin@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series Add VDUSE support to Vhost library |

Commit Message

Maxime Coquelin March 31, 2023, 3:42 p.m. UTC
  This patch implements the VDUSE callback for IOTLB misses,
where it unmaps the pages from the invalidated IOTLB entry

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/vhost/vduse.c | 7 +++++++
 1 file changed, 7 insertions(+)
  

Comments

Chenbo Xia May 9, 2023, 5:32 a.m. UTC | #1
Hi Maxime,

> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Friday, March 31, 2023 11:43 PM
> To: dev@dpdk.org; david.marchand@redhat.com; Xia, Chenbo
> <chenbo.xia@intel.com>; mkp@redhat.com; fbl@redhat.com;
> jasowang@redhat.com; Liang, Cunming <cunming.liang@intel.com>; Xie, Yongji
> <xieyongji@bytedance.com>; echaudro@redhat.com; eperezma@redhat.com;
> amorenoz@redhat.com
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [RFC 20/27] vhost: add VDUSE callback for IOTLB entry removal
> 
> This patch implements the VDUSE callback for IOTLB misses,

for IOTLB entry removal? This commit messages seems the same as patch 19.
You may want to change it :)

Thanks,
Chenbo

> where it unmaps the pages from the invalidated IOTLB entry
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  lib/vhost/vduse.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
> index f46823f589..ff4c9e72f1 100644
> --- a/lib/vhost/vduse.c
> +++ b/lib/vhost/vduse.c
> @@ -32,6 +32,12 @@
>  				(1ULL << VIRTIO_F_IN_ORDER) | \
>  				(1ULL << VIRTIO_F_IOMMU_PLATFORM))
> 
> +static void
> +vduse_iotlb_remove_notify(uint64_t addr, uint64_t offset, uint64_t size)
> +{
> +	munmap((void *)(uintptr_t)addr, offset + size);
> +}
> +
>  static int
>  vduse_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm
> __rte_unused)
>  {
> @@ -89,6 +95,7 @@ vduse_iotlb_miss(struct virtio_net *dev, uint64_t iova,
> uint8_t perm __rte_unuse
> 
>  static struct vhost_backend_ops vduse_backend_ops = {
>  	.iotlb_miss = vduse_iotlb_miss,
> +	.iotlb_remove_notify = vduse_iotlb_remove_notify,
>  };
> 
>  int
> --
> 2.39.2
  
Maxime Coquelin May 25, 2023, 11:35 a.m. UTC | #2
On 5/9/23 07:32, Xia, Chenbo wrote:
> Hi Maxime,
> 
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Sent: Friday, March 31, 2023 11:43 PM
>> To: dev@dpdk.org; david.marchand@redhat.com; Xia, Chenbo
>> <chenbo.xia@intel.com>; mkp@redhat.com; fbl@redhat.com;
>> jasowang@redhat.com; Liang, Cunming <cunming.liang@intel.com>; Xie, Yongji
>> <xieyongji@bytedance.com>; echaudro@redhat.com; eperezma@redhat.com;
>> amorenoz@redhat.com
>> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Subject: [RFC 20/27] vhost: add VDUSE callback for IOTLB entry removal
>>
>> This patch implements the VDUSE callback for IOTLB misses,
> 
> for IOTLB entry removal? This commit messages seems the same as patch 19.
> You may want to change it :)
I indeed need to rework both patches 19 & 20 commit messages.

Thanks for the review,
Maxime

> Thanks,
> Chenbo
> 
>> where it unmaps the pages from the invalidated IOTLB entry
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>> ---
>>   lib/vhost/vduse.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
>> index f46823f589..ff4c9e72f1 100644
>> --- a/lib/vhost/vduse.c
>> +++ b/lib/vhost/vduse.c
>> @@ -32,6 +32,12 @@
>>   				(1ULL << VIRTIO_F_IN_ORDER) | \
>>   				(1ULL << VIRTIO_F_IOMMU_PLATFORM))
>>
>> +static void
>> +vduse_iotlb_remove_notify(uint64_t addr, uint64_t offset, uint64_t size)
>> +{
>> +	munmap((void *)(uintptr_t)addr, offset + size);
>> +}
>> +
>>   static int
>>   vduse_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm
>> __rte_unused)
>>   {
>> @@ -89,6 +95,7 @@ vduse_iotlb_miss(struct virtio_net *dev, uint64_t iova,
>> uint8_t perm __rte_unuse
>>
>>   static struct vhost_backend_ops vduse_backend_ops = {
>>   	.iotlb_miss = vduse_iotlb_miss,
>> +	.iotlb_remove_notify = vduse_iotlb_remove_notify,
>>   };
>>
>>   int
>> --
>> 2.39.2
>
  

Patch

diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
index f46823f589..ff4c9e72f1 100644
--- a/lib/vhost/vduse.c
+++ b/lib/vhost/vduse.c
@@ -32,6 +32,12 @@ 
 				(1ULL << VIRTIO_F_IN_ORDER) | \
 				(1ULL << VIRTIO_F_IOMMU_PLATFORM))
 
+static void
+vduse_iotlb_remove_notify(uint64_t addr, uint64_t offset, uint64_t size)
+{
+	munmap((void *)(uintptr_t)addr, offset + size);
+}
+
 static int
 vduse_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm __rte_unused)
 {
@@ -89,6 +95,7 @@  vduse_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm __rte_unuse
 
 static struct vhost_backend_ops vduse_backend_ops = {
 	.iotlb_miss = vduse_iotlb_miss,
+	.iotlb_remove_notify = vduse_iotlb_remove_notify,
 };
 
 int