DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Wang, YuanX" <yuanx.wang@intel.com>
To: "Xia, Chenbo" <chenbo.xia@intel.com>,
	"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, "Hu, Jiayu" <jiayu.hu@intel.com>,
	"Jiang, Cheng1" <cheng1.jiang@intel.com>,
	"Ma, WenwuX" <wenwux.ma@intel.com>,
	"He, Xingguang" <xingguang.he@intel.com>
Subject: RE: [PATCH v4] net/vhost: support asynchronous data path
Date: Thu, 20 Oct 2022 14:00:18 +0000	[thread overview]
Message-ID: <PH7PR11MB6953C5B1075F167A4857BC28852A9@PH7PR11MB6953.namprd11.prod.outlook.com> (raw)
In-Reply-To: <SN6PR11MB3504593200912A9D77897BA79C2B9@SN6PR11MB3504.namprd11.prod.outlook.com>

Hi Chenbo,

Thanks for your review. Please see replies inline.

> -----Original Message-----
> From: Xia, Chenbo <chenbo.xia@intel.com>
> Sent: Wednesday, October 19, 2022 10:11 PM
> To: Wang, YuanX <yuanx.wang@intel.com>; maxime.coquelin@redhat.com
> Cc: dev@dpdk.org; Hu, Jiayu <jiayu.hu@intel.com>; Jiang, Cheng1
> <cheng1.jiang@intel.com>; Ma, WenwuX <wenwux.ma@intel.com>; He,
> Xingguang <xingguang.he@intel.com>
> Subject: RE: [PATCH v4] net/vhost: support asynchronous data path
> 
> Hi Yuan,
> 
> Overall it looks good to me, two inline comments below.
> 
> > -----Original Message-----
> > From: Wang, YuanX <yuanx.wang@intel.com>
> > Sent: Friday, September 30, 2022 3:47 AM
> > To: maxime.coquelin@redhat.com; Xia, Chenbo <chenbo.xia@intel.com>
> > Cc: dev@dpdk.org; Hu, Jiayu <jiayu.hu@intel.com>; Jiang, Cheng1
> > <cheng1.jiang@intel.com>; Ma, WenwuX <wenwux.ma@intel.com>; He,
> > Xingguang <xingguang.he@intel.com>; Wang, YuanX
> <yuanx.wang@intel.com>
> > Subject: [PATCH v4] net/vhost: support asynchronous data path
> >
> > Vhost asynchronous data-path offloads packet copy from the CPU to the
> > DMA engine. As a result, large packet copy can be accelerated by the
> > DMA engine, and vhost can free CPU cycles for higher level functions.
> >

[...]

> > @@ -486,31 +581,49 @@ eth_vhost_tx(void *q, struct rte_mbuf **bufs,
> > uint16_t nb_bufs)
> >  	}
> >
> >  	/* Enqueue packets to guest RX queue */
> > -	while (nb_send) {
> > -		uint16_t nb_pkts;
> > -		uint16_t num = (uint16_t)RTE_MIN(nb_send,
> > -						 VHOST_MAX_PKT_BURST);
> > +	if (!r->async_register) {
> > +		while (nb_send) {
> > +			num = (uint16_t)RTE_MIN(nb_send,
> VHOST_MAX_PKT_BURST);
> > +			nb_pkts = rte_vhost_enqueue_burst(r->vid, r-
> > >virtqueue_id,
> > +						&bufs[nb_tx], num);
> > +
> > +			nb_tx += nb_pkts;
> > +			nb_send -= nb_pkts;
> > +			if (nb_pkts < num)
> > +				break;
> > +		}
> >
> > -		nb_pkts = rte_vhost_enqueue_burst(r->vid, r->virtqueue_id,
> > -						  &bufs[nb_tx], num);
> > +		for (i = 0; likely(i < nb_tx); i++) {
> > +			nb_bytes += bufs[i]->pkt_len;
> > +			rte_pktmbuf_free(bufs[i]);
> > +		}
> >
> > -		nb_tx += nb_pkts;
> > -		nb_send -= nb_pkts;
> > -		if (nb_pkts < num)
> > -			break;
> > -	}
> > +	} else {
> > +		while (nb_send) {
> > +			num = (uint16_t)RTE_MIN(nb_send,
> VHOST_MAX_PKT_BURST);
> > +			nb_pkts = rte_vhost_submit_enqueue_burst(r->vid,
> r-
> > >virtqueue_id,
> > +							&bufs[nb_tx], num,
> r->dma_id, 0);
> > +
> > +			nb_tx += nb_pkts;
> > +			nb_send -= nb_pkts;
> > +			if (nb_pkts < num)
> > +				break;
> > +		}
> >
> > -	for (i = 0; likely(i < nb_tx); i++)
> > -		nb_bytes += bufs[i]->pkt_len;
> > +		for (i = 0; likely(i < nb_tx); i++)
> > +			nb_bytes += bufs[i]->pkt_len;
> >
> > -	nb_missed = nb_bufs - nb_tx;
> > +		if (unlikely(async_tx_poll_completed)) {
> > +			vhost_tx_free_completed(r->vid, r->virtqueue_id, r-
> > >dma_id, r->cmpl_pkts,
> > +					VHOST_MAX_PKT_BURST);
> > +		}
> > +	}
> 
> About the stats, should we update them when packet is completed?
> Anyway in vhost lib we have inflight xstats, user can know how many packets
> are finished and how many are in-flight.
> 

We think the way it is now makes more sense.

For asynchronous path, the completed packets from rte_vhost_poll_enqueue_completed() may not be the packets of this burst, but from the previous one. 
Using this value for statistics does not accurately reflect the statistics of this burst, 
and makes the missed_pkts definition inconsistent between the synchronous and asynchronous paths.

After rte_vhost_submit_enqueue_burst(), most enqueue process is completed, leaving the DMA copy and update vring index,
while the probability of error in the DMA copy is extremely low (If an error occurs, it can be considered a serious problem,
then the error log recorded, and the data plane should be stopped).
Therefore, the packages submitted to the DMA this burst can be used to represent the completed packages. This statistic is also more in line with the original meaning.

> >

[...]

> > +
> > +static void
> > +cmd_tx_poll_parsed(void *parsed_result, __rte_unused struct cmdline
> > +*cl,
> > __rte_unused void *data)
> > +{
> > +	struct cmd_tx_poll_result *res = parsed_result;
> > +
> > +	if (!strcmp(res->what, "on"))
> > +		rte_eth_vhost_async_tx_poll_completed(true);
> > +	else if (!strcmp(res->what, "off"))
> > +		rte_eth_vhost_async_tx_poll_completed(false);
> > +}
> 
> Sorry I forgot to reply v3. I think it's better to do something like
> 
> fprintf(stderr, "Unknown parameter\n");

Thanks for the suggestion. Will do in v5.

Thanks,
Yuan

> 
> Thanks,
> Chenbo
> 
> > +
> > +static cmdline_parse_inst_t async_vhost_cmd_tx_poll = {
> > +	.f = cmd_tx_poll_parsed,
> > +	.data = NULL,
> > +	.help_str = "async-vhost tx poll completed on|off",
> > +	.tokens = {
> > +		(void *)&cmd_tx_async_vhost,
> > +		(void *)&cmd_tx_tx,
> > +		(void *)&cmd_tx_poll,
> > +		(void *)&cmd_tx_completed,
> > +		(void *)&cmd_tx_what,
> > +		NULL,
> > +	},
> > +};
> > +
> > +static struct testpmd_driver_commands async_vhost_cmds = {
> > +	.commands = {
> > +	{
> > +		&async_vhost_cmd_tx_poll,
> > +		"async_vhost tx poll completed (on|off)\n"
> > +		"    Poll and free DMA completed packets in Tx path.\n",
> > +	},
> > +	{ NULL, NULL },
> > +	},
> > +};
> > +
> > +TESTPMD_ADD_DRIVER_COMMANDS(async_vhost_cmds)
> > --
> > 2.25.1


  reply	other threads:[~2022-10-20 14:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-14 15:06 [PATCH] " Jiayu Hu
2022-08-18  2:05 ` [PATCH v2] " Jiayu Hu
2022-08-23 16:35 ` [PATCH v3] " Yuan Wang
2022-09-26  6:55   ` Xia, Chenbo
2022-09-27  7:34     ` Wang, YuanX
2022-09-28  8:13       ` Wang, YuanX
2022-10-10  5:17   ` Hu, Jiayu
2022-10-18 11:59     ` Xia, Chenbo
2022-09-29 19:47 ` [PATCH v4] " Yuan Wang
2022-10-19 14:10   ` Xia, Chenbo
2022-10-20 14:00     ` Wang, YuanX [this message]
2022-10-24 15:14 ` [PATCH v5] " Yuan Wang
2022-10-24  9:02   ` Xia, Chenbo
2022-10-24  9:25     ` Wang, YuanX
2022-10-24  9:08   ` Maxime Coquelin
2022-10-25  2:14     ` Hu, Jiayu
2022-10-25  7:52       ` Maxime Coquelin
2022-10-25  9:15         ` Hu, Jiayu
2022-10-25 15:33           ` Maxime Coquelin
2022-10-25 15:44             ` Bruce Richardson
2022-10-25 16:04               ` Maxime Coquelin
2022-10-26  2:48                 ` Hu, Jiayu
2022-10-26  5:00                   ` 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=PH7PR11MB6953C5B1075F167A4857BC28852A9@PH7PR11MB6953.namprd11.prod.outlook.com \
    --to=yuanx.wang@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=wenwux.ma@intel.com \
    --cc=xingguang.he@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).