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 2D3F3A04FD for ; Wed, 22 Jun 2022 09:23:40 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 25DF24069C; Wed, 22 Jun 2022 09:23:40 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 1B7DF40689 for ; Wed, 22 Jun 2022 09:23:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655882618; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uKFjKmD3fnLT49yd8PKGeWoQNd4SARS3sUtGNiiX4gQ=; b=OIzKDZ/Fnp/ykUPME/eSFz8Xyyt0entx+EFc4eTteKeCMZCn3juYDyxcb8obKAtCTUztwh mqAPmTnlEIuLdUBe0ASu6o5j97pV4+otOWqMQKGmHCmW/Pyj24Lv477fbTuNiiqz+eJY8M 4tAl9V2aFDTXw8VnsBtV31CqOL18C+o= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-wHpZM_NNNPmB5j3mJzactA-1; Wed, 22 Jun 2022 03:23:34 -0400 X-MC-Unique: wHpZM_NNNPmB5j3mJzactA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EA10D101A5AD; Wed, 22 Jun 2022 07:23:33 +0000 (UTC) Received: from [10.39.208.40] (unknown [10.39.208.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D6E3C4C7A0; Wed, 22 Jun 2022 07:23:32 +0000 (UTC) Message-ID: <1d3c97bf-89e4-7432-35f6-04b3f76cc16b@redhat.com> Date: Wed, 22 Jun 2022 09:23:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v3] examples/vhost: fix retry logic on eth rx path To: Yuan Wang , chenbo.xia@intel.com, dev@dpdk.org Cc: jiayu.hu@intel.com, xingguang.he@intel.com, stable@dpdk.org, Wei Ling References: <20220518162505.1691401-1-yuanx.wang@intel.com> <20220622062741.1140109-1-yuanx.wang@intel.com> From: Maxime Coquelin In-Reply-To: <20220622062741.1140109-1-yuanx.wang@intel.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 6/22/22 08:27, Yuan Wang wrote: > 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") Are you sure about the Fixes tag? It seems to be unrelated to the issue this patch is addressing. > Cc: stable@dpdk.org > > Signed-off-by: Yuan Wang > Tested-by: Wei Ling > --- > V3: Fix mbuf index. > V2: Rebase to 22.07 rc1. > --- > examples/vhost/main.c | 28 +++++++++++----------------- > 1 file changed, 11 insertions(+), 17 deletions(-) > > diff --git a/examples/vhost/main.c b/examples/vhost/main.c > index e7fee5aa1b..0fa6c096c8 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 \n" > " --nb-devices ND\n" > " -p PORTMASK: Set mask for ports to be used by application\n" > @@ -1383,27 +1383,21 @@ 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[enqueue_count], > + rx_count - enqueue_count); > } > } > > - 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);