[v5,3/5] vhost: handle memory hotplug for async vhost
Checks
Commit Message
From: Jiayu Hu <jiayu.hu@intel.com>
When the guest memory is hotplugged, the vhost application which
enables DMA acceleration must stop DMA transfers before the vhost
re-maps the guest memory.
This patch is to notify the vhost application of stopping DMA
transfers.
Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
---
lib/vhost/vhost_user.c | 9 +++++++++
1 file changed, 9 insertions(+)
Comments
Hi Cheng & Jiayu,
> -----Original Message-----
> From: Jiang, Cheng1 <cheng1.jiang@intel.com>
> Sent: Friday, July 16, 2021 3:25 PM
> To: maxime.coquelin@redhat.com; Xia, Chenbo <chenbo.xia@intel.com>
> Cc: dev@dpdk.org; Hu, Jiayu <jiayu.hu@intel.com>; Yang, YvonneX
> <yvonnex.yang@intel.com>
> Subject: [PATCH v5 3/5] vhost: handle memory hotplug for async vhost
>
> From: Jiayu Hu <jiayu.hu@intel.com>
>
> When the guest memory is hotplugged, the vhost application which
> enables DMA acceleration must stop DMA transfers before the vhost
> re-maps the guest memory.
>
> This patch is to notify the vhost application of stopping DMA
> transfers.
>
> Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
> ---
> lib/vhost/vhost_user.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> index 031c578e54..39e8432d1c 100644
> --- a/lib/vhost/vhost_user.c
> +++ b/lib/vhost/vhost_user.c
> @@ -1275,6 +1275,15 @@ vhost_user_set_mem_table(struct virtio_net **pdev,
> struct VhostUserMsg *msg,
> vdpa_dev->ops->dev_close(dev->vid);
> dev->flags &= ~VIRTIO_DEV_VDPA_CONFIGURED;
> }
> +
> + /* notify the backend application to stop DMA transfers */
Backend application -> vhost application
> + if (dev->async_copy && dev->notify_ops->vring_state_changed) {
> + for (i = 0; i < dev->nr_vring; i++) {
> + dev->notify_ops->vring_state_changed(dev->vid,
> + i, 0);
> + }
> + }
> +
In this case, I think app will never know the vring is enabled again with memory
table updated.
Thanks,
Chenbo
> free_mem_region(dev);
> rte_free(dev->mem);
> dev->mem = NULL;
> --
> 2.29.2
> -----Original Message-----
> From: Xia, Chenbo <chenbo.xia@intel.com>
> Sent: Monday, July 19, 2021 1:19 PM
> To: Jiang, Cheng1 <cheng1.jiang@intel.com>; maxime.coquelin@redhat.com;
> Hu, Jiayu <jiayu.hu@intel.com>
> Cc: dev@dpdk.org; Yang, YvonneX <yvonnex.yang@intel.com>
> Subject: RE: [PATCH v5 3/5] vhost: handle memory hotplug for async vhost
>
> Hi Cheng & Jiayu,
>
> > -----Original Message-----
> > From: Jiang, Cheng1 <cheng1.jiang@intel.com>
> > Sent: Friday, July 16, 2021 3:25 PM
> > To: maxime.coquelin@redhat.com; Xia, Chenbo <chenbo.xia@intel.com>
> > Cc: dev@dpdk.org; Hu, Jiayu <jiayu.hu@intel.com>; Yang, YvonneX
> > <yvonnex.yang@intel.com>
> > Subject: [PATCH v5 3/5] vhost: handle memory hotplug for async vhost
> >
> > From: Jiayu Hu <jiayu.hu@intel.com>
> >
> > When the guest memory is hotplugged, the vhost application which
> > enables DMA acceleration must stop DMA transfers before the vhost
> > re-maps the guest memory.
> >
> > This patch is to notify the vhost application of stopping DMA
> > transfers.
> >
> > Signed-off-by: Jiayu Hu <jiayu.hu@intel.com>
> > ---
> > lib/vhost/vhost_user.c | 9 +++++++++
> > 1 file changed, 9 insertions(+)
> >
> > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index
> > 031c578e54..39e8432d1c 100644
> > --- a/lib/vhost/vhost_user.c
> > +++ b/lib/vhost/vhost_user.c
> > @@ -1275,6 +1275,15 @@ vhost_user_set_mem_table(struct virtio_net
> > **pdev, struct VhostUserMsg *msg,
> > vdpa_dev->ops->dev_close(dev->vid);
> > dev->flags &= ~VIRTIO_DEV_VDPA_CONFIGURED;
> > }
> > +
> > + /* notify the backend application to stop DMA transfers */
>
> Backend application -> vhost application
>
> > + if (dev->async_copy && dev->notify_ops-
> >vring_state_changed) {
> > + for (i = 0; i < dev->nr_vring; i++) {
> > + dev->notify_ops->vring_state_changed(dev-
> >vid,
> > + i, 0);
> > + }
> > + }
> > +
>
> In this case, I think app will never know the vring is enabled again with
> memory table updated.
I will add enable notification in set_mem_table.
Thanks,
Jiayu
>
> Thanks,
> Chenbo
>
> > free_mem_region(dev);
> > rte_free(dev->mem);
> > dev->mem = NULL;
> > --
> > 2.29.2
>
@@ -1275,6 +1275,15 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,
vdpa_dev->ops->dev_close(dev->vid);
dev->flags &= ~VIRTIO_DEV_VDPA_CONFIGURED;
}
+
+ /* notify the backend application to stop DMA transfers */
+ if (dev->async_copy && dev->notify_ops->vring_state_changed) {
+ for (i = 0; i < dev->nr_vring; i++) {
+ dev->notify_ops->vring_state_changed(dev->vid,
+ i, 0);
+ }
+ }
+
free_mem_region(dev);
rte_free(dev->mem);
dev->mem = NULL;