From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1D074A00C5 for ; Wed, 3 Aug 2022 11:52:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1285440A7E; Wed, 3 Aug 2022 11:52:18 +0200 (CEST) Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by mails.dpdk.org (Postfix) with ESMTP id 91F9E40141 for ; Wed, 3 Aug 2022 11:52:16 +0200 (CEST) Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 0F4B63F136 for ; Wed, 3 Aug 2022 09:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1659520336; bh=ty5il8EtTOcyl823uBl1Vd+rulPALXLoJxds9XfLf/w=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ComdUi7DRkYRV5lx4W1mS6x9gHpWwqZxhIvnkgMb1IMWyd2wcdX9NypOmV0V0c3ce egTxBa1z3ZDh0qVN8s9oVL7zT2nuciqI+iYujBHoDYV0YHKcNGbLJOL9c8lb9Xh2ty Wi8rkAfCX3SJqW/f+JPUBR8AZVWkYbTH8IvHaOC1BXNbLEiUaweZTjbg+vzw2AAZZK ygXQtk8qcBNoggfMcmsKqUfmVUKRqEOsviQFMtJJi5XNlQsJYminiFefEmgN9EujhE BmH/SS1H+GRYQjujEBUDYT7ETihhBbKiT5pvVWHS5Px0k6fq9+/aJik/BLisnfgNM5 Qm09/bp0zQvMw== Received: by mail-lj1-f199.google.com with SMTP id j15-20020a2e850f000000b0025e6da69e18so232281lji.18 for ; Wed, 03 Aug 2022 02:52:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=ty5il8EtTOcyl823uBl1Vd+rulPALXLoJxds9XfLf/w=; b=aJGsxGTCOsUmHhAWEVHD6n004Sj1dPmXj878RjoDiCcpojBDnm1U3yjUuZnuSmcieO PGh86+YrDn6Xk7s6oCS/hrmnb2HwS94QdY+h3nBALqBkImH7BVPBCr7ZU9DD0A1O1yOM MS5Gt3zpeRiovgeMFYIzpdjXROVPr0ElAamynUHuhbegk+HKlkUc20T2nXNWR0C5QLGN kayhD4xfXIRZjAz2cN81+xfZyJ5swqY6kHhGeY5pz2bV0uxKSfvQlZCm/6NzaMoemYCF DUi++PRS3CuuyeUAxkPLP6BMVaz16BSAVDuOYrBzljWaeEzwfhK55WlDi+/5ltTGh9La /a8w== X-Gm-Message-State: ACgBeo097mgf9VERw0pzQqsvBFiSbi4sEzi5vuuzECstk1ZDfVKaaHd1 PIneWn+SpSsvXpeID3/IRSMjjNFf3s2ZwU3Fv8q9t77XhdlMUhT8GqwdpK/sjIbDeDeX82pmRiw RfUr3EfHNw60GnkCLge+NnvMlvHMt2Sff6b9o3+Sf X-Received: by 2002:a05:6512:e88:b0:48a:f6aa:84a7 with SMTP id bi8-20020a0565120e8800b0048af6aa84a7mr5329678lfb.395.1659520333284; Wed, 03 Aug 2022 02:52:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR6QWzRJUtLVDMRumdyxN4sTsGFSrZciZHZ0aZFDcYGJAz6V+CaTnw1dguXt2D0FPSThyk7huwAirczI2gZ4CVY= X-Received: by 2002:a05:6512:e88:b0:48a:f6aa:84a7 with SMTP id bi8-20020a0565120e8800b0048af6aa84a7mr5329672lfb.395.1659520333062; Wed, 03 Aug 2022 02:52:13 -0700 (PDT) MIME-Version: 1.0 References: <20220715153135.566982-1-yuanx.wang@intel.com> In-Reply-To: <20220715153135.566982-1-yuanx.wang@intel.com> From: Christian Ehrhardt Date: Wed, 3 Aug 2022 11:51:47 +0200 Message-ID: Subject: Re: [PATCH 19.11] examples/vhost: fix retry logic on Rx path To: Yuan Wang Cc: stable@dpdk.org, maxime.coquelin@redhat.com, chenbo.xia@intel.com, jiayu.hu@intel.com, cheng1.jiang@intel.com, qiming.yang@intel.com Content-Type: text/plain; charset="UTF-8" X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Fri, Jul 15, 2022 at 9:43 AM Yuan Wang 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 > Reviewed-by: Chenbo Xia > --- > 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