From: "Wang, YuanX" <yuanx.wang@intel.com>
To: "Xia, Chenbo" <chenbo.xia@intel.com>,
"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>,
"dev@dpdk.org" <dev@dpdk.org>
Cc: "Hu, Jiayu" <jiayu.hu@intel.com>,
"He, Xingguang" <xingguang.he@intel.com>,
"stable@dpdk.org" <stable@dpdk.org>,
"Ling, WeiX" <weix.ling@intel.com>
Subject: RE: [PATCH v2] examples/vhost: fix retry logic on eth rx path
Date: Wed, 22 Jun 2022 02:26:14 +0000 [thread overview]
Message-ID: <SA2PR11MB49063279451C123E84EF778685B29@SA2PR11MB4906.namprd11.prod.outlook.com> (raw)
In-Reply-To: <SN6PR11MB35049FE6DD181B96EA3B0D889CB39@SN6PR11MB3504.namprd11.prod.outlook.com>
Hi Chenbo,
> -----Original Message-----
> From: Xia, Chenbo <chenbo.xia@intel.com>
> Sent: Tuesday, June 21, 2022 9:35 PM
> To: Wang, YuanX <yuanx.wang@intel.com>; maxime.coquelin@redhat.com;
> dev@dpdk.org
> Cc: Hu, Jiayu <jiayu.hu@intel.com>; He, Xingguang
> <xingguang.he@intel.com>; stable@dpdk.org; Ling, WeiX
> <weix.ling@intel.com>
> Subject: RE: [PATCH v2] examples/vhost: fix retry logic on eth rx path
>
> Hi Yuan,
>
> > -----Original Message-----
> > From: Wang, YuanX <yuanx.wang@intel.com>
> > Sent: Friday, June 17, 2022 3:02 PM
> > To: maxime.coquelin@redhat.com; Xia, Chenbo <chenbo.xia@intel.com>;
> > dev@dpdk.org
> > Cc: Hu, Jiayu <jiayu.hu@intel.com>; He, Xingguang
> > <xingguang.he@intel.com>; Wang, YuanX <yuanx.wang@intel.com>;
> > stable@dpdk.org; Ling, WeiX <weix.ling@intel.com>
> > Subject: [PATCH v2] examples/vhost: fix retry logic on eth rx path
> >
> > drain_eth_rx() uses rte_vhost_avail_entries() to calculate the
> > available entries to determine if a retry is required.
> > However, this function only works with split rings, and calculating
> > packed rings will return the wrong value and cause unnecessary retries
> > resulting in a significant performance penalty.
> >
> > This patch fix that by using the difference between tx/rx burst as the
> > retry condition.
> >
> > Fixes: 4ecf22e356de ("vhost: export device id as the interface to
> > applications")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Yuan Wang <yuanx.wang@intel.com>
> > Tested-by: Wei Ling <weix.ling@intel.com>
> > ---
> > V2: Rebase to 22.07 rc1.
> > ---
> > examples/vhost/main.c | 27 ++++++++++-----------------
> > 1 file changed, 10 insertions(+), 17 deletions(-)
> >
> > diff --git a/examples/vhost/main.c b/examples/vhost/main.c index
> > e7fee5aa1b..e7a84333ed 100644
> > --- a/examples/vhost/main.c
> > +++ b/examples/vhost/main.c
> > @@ -634,7 +634,7 @@ us_vhost_usage(const char *prgname) {
> > RTE_LOG(INFO, VHOST_CONFIG, "%s [EAL options] -- -p
> PORTMASK\n"
> > " --vm2vm [0|1|2]\n"
> > - " --rx_retry [0|1] --mergeable [0|1] --stats [0-N]\n"
> > + " --rx-retry [0|1] --mergeable [0|1] --stats [0-N]\n"
> > " --socket-file <path>\n"
> > " --nb-devices ND\n"
> > " -p PORTMASK: Set mask for ports to be used by
> > application\n"
> > @@ -1383,27 +1383,20 @@ drain_eth_rx(struct vhost_dev *vdev)
> > if (!rx_count)
> > return;
> >
> > - /*
> > - * When "enable_retry" is set, here we wait and retry when there
> > - * is no enough free slots in the queue to hold @rx_count packets,
> > - * to diminish packet loss.
> > - */
> > - if (enable_retry &&
> > - unlikely(rx_count > rte_vhost_avail_entries(vdev->vid,
> > - VIRTIO_RXQ))) {
> > - uint32_t retry;
> > + enqueue_count = vdev_queue_ops[vdev-
> >vid].enqueue_pkt_burst(vdev,
> > + VIRTIO_RXQ, pkts, rx_count);
> >
> > - for (retry = 0; retry < burst_rx_retry_num; retry++) {
> > + /* Retry if necessary */
> > + if (enable_retry && unlikely(enqueue_count < rx_count)) {
> > + uint32_t retry = 0;
> > +
> > + while (enqueue_count < rx_count && retry++ <
> > burst_rx_retry_num) {
> > rte_delay_us(burst_rx_delay_time);
> > - if (rx_count <= rte_vhost_avail_entries(vdev->vid,
> > - VIRTIO_RXQ))
> > - break;
> > + enqueue_count += vdev_queue_ops[vdev-
> > >vid].enqueue_pkt_burst(vdev,
> > + VIRTIO_RXQ,
> pkts,
> > rx_count);
>
> Looking at the code again, it seems current logic will enqueue more than
> rx_count packets and same packet may be sent multiple times as you are
> enqueue multiple times but using the same mbuf pointer and rx_count.
>
Thanks for pointing that out, I did miss the packet index.
Will fix in the next version.
Thanks,
Yuan
> Thanks,
> Chenbo
>
> > }
> > }
> >
> > - enqueue_count = vdev_queue_ops[vdev-
> >vid].enqueue_pkt_burst(vdev,
> > - VIRTIO_RXQ, pkts, rx_count);
> > -
> > if (enable_stats) {
> > __atomic_add_fetch(&vdev->stats.rx_total_atomic,
> rx_count,
> > __ATOMIC_SEQ_CST);
> > --
> > 2.25.1
next prev parent reply other threads:[~2022-06-22 2:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-18 16:25 [PATCH] examples/vhost: Fix retry logic on Rx Yuan Wang
2022-05-26 9:30 ` Ling, WeiX
2022-06-17 7:01 ` [PATCH v2] examples/vhost: fix retry logic on eth rx path Yuan Wang
2022-06-20 3:20 ` Xia, Chenbo
2022-06-20 7:36 ` David Marchand
2022-06-20 7:49 ` Xia, Chenbo
2022-06-20 8:59 ` Hu, Jiayu
2022-06-20 9:09 ` Xia, Chenbo
2022-06-20 9:19 ` Wang, YuanX
2022-06-20 9:33 ` Xia, Chenbo
2022-06-20 9:42 ` Hu, Jiayu
2022-06-21 13:34 ` Xia, Chenbo
2022-06-22 2:26 ` Wang, YuanX [this message]
2022-06-22 6:27 ` [PATCH v3] " Yuan Wang
2022-06-22 7:23 ` Maxime Coquelin
2022-06-22 8:50 ` Wang, YuanX
2022-06-22 9:25 ` [PATCH v4] " Yuan Wang
2022-06-23 2:57 ` Xia, Chenbo
2022-06-23 7:20 ` Ling, WeiX
2022-07-01 13:57 ` 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=SA2PR11MB49063279451C123E84EF778685B29@SA2PR11MB4906.namprd11.prod.outlook.com \
--to=yuanx.wang@intel.com \
--cc=chenbo.xia@intel.com \
--cc=dev@dpdk.org \
--cc=jiayu.hu@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=stable@dpdk.org \
--cc=weix.ling@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).