DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Ding, Xuan" <xuan.ding@intel.com>
To: "Xia, Chenbo" <chenbo.xia@intel.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>
Cc: "Hu, Jiayu" <jiayu.hu@intel.com>,
	"Jiang, Cheng1" <cheng1.jiang@intel.com>,
	"Richardson, Bruce" <bruce.richardson@intel.com>,
	"Pai G, Sunil" <sunil.pai.g@intel.com>
Subject: Re: [dpdk-dev] [PATCH] vhost: add unsafe API to check inflight packets
Date: Wed, 15 Sep 2021 07:10:26 +0000	[thread overview]
Message-ID: <BN9PR11MB55137B8B2264E9CB9A9ABFCAE7DB9@BN9PR11MB5513.namprd11.prod.outlook.com> (raw)
In-Reply-To: <MN2PR11MB4063D0CE840C3B8F7FB497909CDB9@MN2PR11MB4063.namprd11.prod.outlook.com>

Hi Chenbo,

> -----Original Message-----
> From: Xia, Chenbo <chenbo.xia@intel.com>
> Sent: Wednesday, September 15, 2021 2:49 PM
> To: Ding, Xuan <xuan.ding@intel.com>; dev@dpdk.org;
> maxime.coquelin@redhat.com
> Cc: Hu, Jiayu <jiayu.hu@intel.com>; cheng.jiang@intel.com; Richardson, Bruce
> <bruce.richardson@intel.com>; Pai G, Sunil <sunil.pai.g@intel.com>
> Subject: RE: [PATCH] vhost: add unsafe API to check inflight packets
> 
> Hi Xuan,
> 
> > -----Original Message-----
> > From: Ding, Xuan <xuan.ding@intel.com>
> > Sent: Thursday, September 9, 2021 1:58 PM
> > To: dev@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo
> > <chenbo.xia@intel.com>
> > Cc: Hu, Jiayu <jiayu.hu@intel.com>; cheng.jiang@intel.com; Richardson, Bruce
> > <bruce.richardson@intel.com>; Pai G, Sunil <sunil.pai.g@intel.com>; Ding,
> Xuan
> > <xuan.ding@intel.com>
> > Subject: [PATCH] vhost: add unsafe API to check inflight packets
> >
> > In async data path, when vring state changes, it is necessary to
> > know the number of inflight packets in DMA engine. This patch
> > provides a thread unsafe API to return the number of inflight
> > packets without using any lock.
> >
> > Signed-off-by: Xuan Ding <xuan.ding@intel.com>
> > ---
> >  doc/guides/prog_guide/vhost_lib.rst    |  5 +++++
> >  doc/guides/rel_notes/release_21_11.rst |  5 +++++
> >  lib/vhost/rte_vhost_async.h            | 14 ++++++++++++++
> >  lib/vhost/version.map                  |  3 +++
> >  lib/vhost/vhost.c                      | 25 +++++++++++++++++++++++++
> >  5 files changed, 52 insertions(+)
> >
> > diff --git a/doc/guides/prog_guide/vhost_lib.rst
> > b/doc/guides/prog_guide/vhost_lib.rst
> > index 8874033165..b4b1134f54 100644
> > --- a/doc/guides/prog_guide/vhost_lib.rst
> > +++ b/doc/guides/prog_guide/vhost_lib.rst
> > @@ -305,6 +305,11 @@ The following is an overview of some key Vhost API
> > functions:
> >    This function returns the amount of in-flight packets for the vhost
> >    queue using async acceleration.
> >
> > +    ``rte_vhost_async_get_inflight_thread_unsafe(vid, queue_id)``
> > +
> > +  Get the number of inflight packets for a vhost queue without
> > +  performing any locking.
> > +
> >  * ``rte_vhost_clear_queue_thread_unsafe(vid, queue_id, **pkts, count)``
> 
> This does not align with others. Please check.

Thanks, will fix it in next version.

> 
> >
> >    Clear inflight packets which are submitted to DMA engine in vhost async
> > data
> > diff --git a/doc/guides/rel_notes/release_21_11.rst
> > b/doc/guides/rel_notes/release_21_11.rst
> > index 675b573834..db080e9490 100644
> > --- a/doc/guides/rel_notes/release_21_11.rst
> > +++ b/doc/guides/rel_notes/release_21_11.rst
> > @@ -55,6 +55,11 @@ New Features
> >       Also, make sure to start the actual text at the margin.
> >       =======================================================
> >
> > +* **Added vhost API to get the number of inflight packets.**
> > +
> > +  Added an API which can get the number of inflight packets in
> > +  vhost async data path.
> > +
> 
> Please add 'without lock' or something similar as we already have a lock version.

You are right, add "without lock" is more accuracy.

> 
> >  * **Enabled new devargs parser.**
> >
> >    * Enabled devargs syntax
> > diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h
> > index b25ff446f7..0af414bf78 100644
> > --- a/lib/vhost/rte_vhost_async.h
> > +++ b/lib/vhost/rte_vhost_async.h
> > @@ -246,6 +246,20 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid,
> > uint16_t queue_id,
> >  __rte_experimental
> >  int rte_vhost_async_get_inflight(int vid, uint16_t queue_id);
> >
> > +/**
> > + * This function is lock-free version to return the amount of in-flight
> > + * packets for the vhost queue which uses async channel acceleration.
> > + *
> > + * @param vid
> > + *  id of vhost device to enqueue data
> > + * @param queue_id
> > + *  queue id to enqueue data
> 
> You can also check dequeue inflight packets, right?

Yes, this API applies to both enqueue and dequeue directions.

> 
> > + * @return
> > + *  the amount of in-flight packets on success; -1 on failure
> > + */
> > +__rte_experimental
> > +int rte_vhost_async_get_inflight_thread_unsafe(int vid, uint16_t queue_id);
> > +
> >  /**
> >   * This function checks async completion status and clear packets for
> >   * a specific vhost device queue. Packets which are inflight will be
> > diff --git a/lib/vhost/version.map b/lib/vhost/version.map
> > index c92a9d4962..b150dc408d 100644
> > --- a/lib/vhost/version.map
> > +++ b/lib/vhost/version.map
> > @@ -85,4 +85,7 @@ EXPERIMENTAL {
> >  	rte_vhost_async_channel_register_thread_unsafe;
> >  	rte_vhost_async_channel_unregister_thread_unsafe;
> >  	rte_vhost_clear_queue_thread_unsafe;
> > +
> > +	#added in 21.11
> > +	rte_vhost_async_get_inflight_thread_unsafe;
> >  };
> > diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
> > index 355ff37651..df96f84873 100644
> > --- a/lib/vhost/vhost.c
> > +++ b/lib/vhost/vhost.c
> > @@ -1886,5 +1886,30 @@ int rte_vhost_async_get_inflight(int vid, uint16_t
> > queue_id)
> >  	return ret;
> >  }
> >
> > +int rte_vhost_async_get_inflight_thread_unsafe(int vid, uint16_t queue_id)
> 
> According to DPDK coding style, return type and func name should be in
> different
> lines. I notice there are also some left to clean. May clean in another patch.

Thanks, notice the rte_vhost_async_get_inflight() API also has this problem.
Will fix both in next version.

Regards,
Xuan

> 
> Thanks,
> Chenbo
> 
> > +{
> > +	struct vhost_virtqueue *vq;
> > +	struct virtio_net *dev = get_device(vid);
> > +	int ret = -1;
> > +
> > +	if (dev == NULL)
> > +		return ret;
> > +
> > +	if (queue_id >= VHOST_MAX_VRING)
> > +		return ret;
> > +
> > +	vq = dev->virtqueue[queue_id];
> > +
> > +	if (vq == NULL)
> > +		return ret;
> > +
> > +	if (!vq->async_registered)
> > +		return ret;
> > +
> > +	ret = vq->async_pkts_inflight_n;
> > +
> > +	return ret;
> > +}
> > +
> >  RTE_LOG_REGISTER_SUFFIX(vhost_config_log_level, config, INFO);
> >  RTE_LOG_REGISTER_SUFFIX(vhost_data_log_level, data, WARNING);
> > --
> > 2.17.1


  reply	other threads:[~2021-09-15  7:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  5:57 Xuan Ding
2021-09-15  6:49 ` Xia, Chenbo
2021-09-15  7:10   ` Ding, Xuan [this message]
2021-09-15  8:52 ` [dpdk-dev] [PATCH v2 v2] " Xuan Ding
2021-09-16  2:58 ` [dpdk-dev] [PATCH v3] " Xuan Ding
2021-09-21 17:27   ` Kevin Traynor
2021-09-23  2:40     ` Ding, Xuan
2021-09-27  1:42 ` [dpdk-dev] [PATCH v4 0/2] add unsafe API to get " Xuan Ding
2021-09-27  1:42   ` [dpdk-dev] [PATCH v4 1/2] vhost: add unsafe API to check " Xuan Ding
2021-09-27  1:42   ` [dpdk-dev] [PATCH v4 2/2] examples/vhost: use " Xuan Ding
2021-09-28  6:24 ` [dpdk-dev] [PATCH v5 0/2] add unsafe API to get " Xuan Ding
2021-09-28  6:24   ` [dpdk-dev] [PATCH v5 1/2] vhost: add unsafe API to check " Xuan Ding
2021-09-28  6:24   ` [dpdk-dev] [PATCH v5 2/2] examples/vhost: use " Xuan Ding
2021-09-28  9:17     ` Kevin Traynor
2021-09-28 11:50       ` Ding, Xuan
2021-09-28 11:59         ` Ding, Xuan
2021-09-28 15:55 ` [dpdk-dev] [PATCH v6 0/2] add unsafe API to get " Xuan Ding
2021-09-28 15:55   ` [dpdk-dev] [PATCH v6 1/2] vhost: add unsafe API to check " Xuan Ding
2021-09-28 15:55   ` [dpdk-dev] [PATCH v6 2/2] examples/vhost: use " Xuan Ding

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=BN9PR11MB55137B8B2264E9CB9A9ABFCAE7DB9@BN9PR11MB5513.namprd11.prod.outlook.com \
    --to=xuan.ding@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=chenbo.xia@intel.com \
    --cc=cheng1.jiang@intel.com \
    --cc=dev@dpdk.org \
    --cc=jiayu.hu@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=sunil.pai.g@intel.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).