DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Xueming(Steven) Li" <xuemingl@nvidia.com>
To: "maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "chenbo.xia@intel.com" <chenbo.xia@intel.com>
Subject: Re: [dpdk-dev] [PATCH] vhost: add vDPA resource cleanup callback
Date: Thu, 21 Oct 2021 12:35:43 +0000	[thread overview]
Message-ID: <04f60f8da1819b8a0196cfca20127107bd0b835c.camel@nvidia.com> (raw)
In-Reply-To: <2bfda127-f6de-d3fa-0903-566b8ec69be4@redhat.com>

On Thu, 2021-10-21 at 14:00 +0200, Maxime Coquelin wrote:
> Hi Xueming,
> 
> On 10/19/21 13:39, Xueming Li wrote:
> > This patch adds vDPA device cleanup callback to release resources on
> > vhost user connection close.
> > 
> > Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> > ---
> >   lib/vhost/rte_vdpa_dev.h | 3 +++
> >   lib/vhost/vhost_user.c   | 6 ++++++
> >   2 files changed, 9 insertions(+)
> > 
> > diff --git a/lib/vhost/rte_vdpa_dev.h b/lib/vhost/rte_vdpa_dev.h
> > index b0f494815fa..2711004fe05 100644
> > --- a/lib/vhost/rte_vdpa_dev.h
> > +++ b/lib/vhost/rte_vdpa_dev.h
> > @@ -32,6 +32,9 @@ struct rte_vdpa_dev_ops {
> >   	/** Driver close the device (Mandatory) */
> >   	int (*dev_close)(int vid);
> >   
> > +	/** Connection closed, clean up resources */
> > +	int (*dev_cleanup)(int vid);
> > +
> >   	/** Enable/disable this vring (Mandatory) */
> >   	int (*set_vring_state)(int vid, int vring, int state);
> >   
> > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c
> > index 5a894ca0cc7..032b621c86c 100644
> > --- a/lib/vhost/vhost_user.c
> > +++ b/lib/vhost/vhost_user.c
> > @@ -162,6 +162,12 @@ free_mem_region(struct virtio_net *dev)
> >   void
> >   vhost_backend_cleanup(struct virtio_net *dev)
> >   {
> > +	struct rte_vdpa_device *vdpa_dev;
> > +
> > +	vdpa_dev = dev->vdpa_dev;
> > +	if (vdpa_dev && vdpa_dev->ops->dev_cleanup != NULL)
> > +		vdpa_dev->ops->dev_cleanup(dev->vid);
> > +
> >   	if (dev->mem) {
> >   		free_mem_region(dev);
> >   		rte_free(dev->mem);
> > 
> 
> What will be done there that cannot be done in .dev_close()?

.dev_close() mainly handles VM suspend and driver reset. If release
everything inside dev_close(), the suspend and resume takes longer time
if number of VQs are huge. Customer want to upgrade VM configuration
using suspend and resume, pause customer VM too long can't be accepted.
So the idea is to cache and reuse resource between dev_close() and
dev_conf(). Actually, the two functions looks more like dev_stop() and
dev_start().

dev_cleanup hooks to vhost backend cleanup which called when socket
closed for both client and server mode, a safe point to cleanup all
cached resources.

> Having the mlx5 implementation of this callback alongside this patch may
> help to understand.

The mlx5 implementation still a prototype, pending on internal review.
So I just post the vhost part to get suggestion/comment. Let me know if
the ugly code does help :)

> 
> Thanks,
> Maxime
> 


  reply	other threads:[~2021-10-21 12:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19 11:39 Xueming Li
2021-10-21 12:00 ` Maxime Coquelin
2021-10-21 12:35   ` Xueming(Steven) Li [this message]
2021-11-03  8:41     ` Xia, Chenbo
2021-11-03  8:46       ` Maxime Coquelin
2021-11-03 13:45         ` Xueming(Steven) Li
2021-11-03 13:49           ` Maxime Coquelin
2022-01-26 10:03             ` Maxime Coquelin
2022-01-27  8:48               ` Xueming(Steven) Li
2021-11-03 13:42       ` [dpdk-dev] " Xueming(Steven) Li
2022-01-27  8:45 ` [PATCH v2] " Xueming Li
2022-02-03 13:47   ` Maxime Coquelin
2022-02-10 15:13   ` Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=04f60f8da1819b8a0196cfca20127107bd0b835c.camel@nvidia.com \
    --to=xuemingl@nvidia.com \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).