[PATCH 19.11] examples/vhost: fix retry logic on Rx path
Christian Ehrhardt
christian.ehrhardt at canonical.com
Wed Aug 3 11:51:47 CEST 2022
On Fri, Jul 15, 2022 at 9:43 AM Yuan Wang <yuanx.wang at 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 at intel.com>
> Reviewed-by: Chenbo Xia <chenbo.xia at 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
More information about the stable
mailing list