From: Christian Ehrhardt <christian.ehrhardt@canonical.com>
To: Yuan Wang <yuanx.wang@intel.com>
Cc: stable@dpdk.org, maxime.coquelin@redhat.com,
chenbo.xia@intel.com, jiayu.hu@intel.com,
cheng1.jiang@intel.com, qiming.yang@intel.com
Subject: Re: [PATCH 19.11] examples/vhost: fix retry logic on Rx path
Date: Wed, 3 Aug 2022 11:51:47 +0200 [thread overview]
Message-ID: <CAATJJ0LK9_=Cc66Y8BE0+pe9E9cBN2KH+8X9+cLWRxEX3UeAsg@mail.gmail.com> (raw)
In-Reply-To: <20220715153135.566982-1-yuanx.wang@intel.com>
On Fri, Jul 15, 2022 at 9:43 AM Yuan Wang <yuanx.wang@intel.com> wrote:
>
> [ upstream commit 1907ce4baec392a750fbeba5e946920b2f00ae73 ]
Thank you,
your patch was in time, but sadly a few fell through the cracks on my side.
(and many more just arrived too late).
Your patch is applied to the WIP branch now, but currently testing of
-rc1 is going on which I do not want to disrupt.
If we need an -rc2 anyway or generally have the time to do an -rc2
without too much disruption it will be in 19.11.13, otherwise it is
already queued for 19.11.14
> 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: be800696c26e ("examples/vhost: use burst enqueue and dequeue from lib")
>
> Signed-off-by: Yuan Wang <yuanx.wang@intel.com>
> Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
> ---
> examples/vhost/main.c | 40 ++++++++++++++++++++++------------------
> 1 file changed, 22 insertions(+), 18 deletions(-)
>
> diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> index 073668022..ca6e9a332 100644
> --- a/examples/vhost/main.c
> +++ b/examples/vhost/main.c
> @@ -1051,24 +1051,6 @@ 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;
> -
> - for (retry = 0; retry < burst_rx_retry_num; retry++) {
> - rte_delay_us(burst_rx_delay_time);
> - if (rx_count <= rte_vhost_avail_entries(vdev->vid,
> - VIRTIO_RXQ))
> - break;
> - }
> - }
> -
> if (builtin_net_driver) {
> enqueue_count = vs_enqueue_pkts(vdev, VIRTIO_RXQ,
> pkts, rx_count);
> @@ -1076,6 +1058,28 @@ drain_eth_rx(struct vhost_dev *vdev)
> enqueue_count = rte_vhost_enqueue_burst(vdev->vid, VIRTIO_RXQ,
> pkts, rx_count);
> }
> +
> + /* 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 (builtin_net_driver) {
> + enqueue_count += vs_enqueue_pkts(vdev,
> + VIRTIO_RXQ, &pkts[enqueue_count],
> + rx_count - enqueue_count);
> + } else {
> + enqueue_count += rte_vhost_enqueue_burst(
> + vdev->vid,
> + VIRTIO_RXQ,
> + &pkts[enqueue_count],
> + rx_count - enqueue_count);
> + }
> + }
> + }
> +
> if (enable_stats) {
> rte_atomic64_add(&vdev->stats.rx_total_atomic, rx_count);
> rte_atomic64_add(&vdev->stats.rx_atomic, enqueue_count);
> --
> 2.25.1
>
--
Christian Ehrhardt
Senior Staff Engineer, Ubuntu Server
Canonical Ltd
prev parent reply other threads:[~2022-08-03 9:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-15 15:31 Yuan Wang
2022-08-03 9:51 ` Christian Ehrhardt [this message]
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='CAATJJ0LK9_=Cc66Y8BE0+pe9E9cBN2KH+8X9+cLWRxEX3UeAsg@mail.gmail.com' \
--to=christian.ehrhardt@canonical.com \
--cc=chenbo.xia@intel.com \
--cc=cheng1.jiang@intel.com \
--cc=jiayu.hu@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=qiming.yang@intel.com \
--cc=stable@dpdk.org \
--cc=yuanx.wang@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).