[v2,3/5] vhost: handle memory hotplug with vDPA devices

Message ID 1593092298-52257-4-git-send-email-matan@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series vhost: improve ready state |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Matan Azrad June 25, 2020, 1:38 p.m. UTC
  Some vDPA drivers' basic configurations should be updated when the
guest memory is hotplugged.

Close vDPA device before hotplug operation and recreate it after the
hotplug operation is done.

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 lib/librte_vhost/vhost_user.c | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Comments

Maxime Coquelin June 26, 2020, 12:15 p.m. UTC | #1
On 6/25/20 3:38 PM, Matan Azrad wrote:
> Some vDPA drivers' basic configurations should be updated when the
> guest memory is hotplugged.
> 
> Close vDPA device before hotplug operation and recreate it after the
> hotplug operation is done.
> 
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
>  lib/librte_vhost/vhost_user.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index b90fc78..f690fdb 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -1073,6 +1073,15 @@
>  	}
>  
>  	if (dev->mem) {
> +		if (dev->flags & VIRTIO_DEV_VDPA_CONFIGURED) {
> +			int did = dev->vdpa_dev_id;
> +			struct rte_vdpa_device *vdpa_dev =
> +						rte_vdpa_get_device(did);
> +
> +			if (vdpa_dev && vdpa_dev->ops->dev_close)
> +				vdpa_dev->ops->dev_close(dev->vid);
> +			dev->flags &= ~VIRTIO_DEV_VDPA_CONFIGURED;
> +		}
>  		free_mem_region(dev);
>  		rte_free(dev->mem);
>  		dev->mem = NULL;
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  
Chenbo Xia June 28, 2020, 3:18 a.m. UTC | #2
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Matan Azrad
> Sent: Thursday, June 25, 2020 9:38 PM
> To: Maxime Coquelin <maxime.coquelin@redhat.com>
> Cc: dev@dpdk.org; Wang, Xiao W <xiao.w.wang@intel.com>
> Subject: [dpdk-dev] [PATCH v2 3/5] vhost: handle memory hotplug with vDPA
> devices
> 
> Some vDPA drivers' basic configurations should be updated when the guest
> memory is hotplugged.
> 
> Close vDPA device before hotplug operation and recreate it after the hotplug
> operation is done.
> 
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> ---
>  lib/librte_vhost/vhost_user.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index
> b90fc78..f690fdb 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -1073,6 +1073,15 @@
>  	}
> 
>  	if (dev->mem) {
> +		if (dev->flags & VIRTIO_DEV_VDPA_CONFIGURED) {
> +			int did = dev->vdpa_dev_id;
> +			struct rte_vdpa_device *vdpa_dev =
> +						rte_vdpa_get_device(did);
> +
> +			if (vdpa_dev && vdpa_dev->ops->dev_close)
> +				vdpa_dev->ops->dev_close(dev->vid);
> +			dev->flags &= ~VIRTIO_DEV_VDPA_CONFIGURED;
> +		}

For now, this solution is general for all vendors. Later we may improve this by calling vendor's
callback as they may behave differently. For now this looks good to me :) (sorry that the reply
is late for memory hotplug discussion because of holiday). Thanks!

>  		free_mem_region(dev);
>  		rte_free(dev->mem);
>  		dev->mem = NULL;
> --
> 1.8.3.1

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  

Patch

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index b90fc78..f690fdb 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1073,6 +1073,15 @@ 
 	}
 
 	if (dev->mem) {
+		if (dev->flags & VIRTIO_DEV_VDPA_CONFIGURED) {
+			int did = dev->vdpa_dev_id;
+			struct rte_vdpa_device *vdpa_dev =
+						rte_vdpa_get_device(did);
+
+			if (vdpa_dev && vdpa_dev->ops->dev_close)
+				vdpa_dev->ops->dev_close(dev->vid);
+			dev->flags &= ~VIRTIO_DEV_VDPA_CONFIGURED;
+		}
 		free_mem_region(dev);
 		rte_free(dev->mem);
 		dev->mem = NULL;