From: Yuan Wang <yuanx.wang@intel.com>
To: christian.ehrhardt@canonical.com, stable@dpdk.org
Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com,
jiayu.hu@intel.com, cheng1.jiang@intel.com,
qiming.yang@intel.com, Yuan Wang <yuanx.wang@intel.com>
Subject: [PATCH 19.11] examples/vhost: fix retry logic on Rx path
Date: Fri, 15 Jul 2022 23:31:35 +0800 [thread overview]
Message-ID: <20220715153135.566982-1-yuanx.wang@intel.com> (raw)
[ upstream commit 1907ce4baec392a750fbeba5e946920b2f00ae73 ]
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
next reply other threads:[~2022-07-15 7:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-15 15:31 Yuan Wang [this message]
2022-08-03 9:51 ` Christian Ehrhardt
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=20220715153135.566982-1-yuanx.wang@intel.com \
--to=yuanx.wang@intel.com \
--cc=chenbo.xia@intel.com \
--cc=cheng1.jiang@intel.com \
--cc=christian.ehrhardt@canonical.com \
--cc=jiayu.hu@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=qiming.yang@intel.com \
--cc=stable@dpdk.org \
/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).