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 B7479A00C5 for ; Wed, 22 Jun 2022 04:26:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA7E340A87; Wed, 22 Jun 2022 04:26:21 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id F08C34014F; Wed, 22 Jun 2022 04:26:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655864779; x=1687400779; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=9AA1O8L15l1hvOmu1J14QdxG47LTHVKvDYcekasEo/o=; b=JQYPCWSPsMcMHtJfoC2gQV5KcGq6Y8cUN/YGvAU/rovAkNsyjFi10PJp fjSQdUJIQisXbxKm7w44mqKTPE4ghEjFer+PTDN7Mw4QcNd9y0h5XO+Gk dmEWZpdzLXPVQ9maolh1xrxHdnBgnXREB0IfFdVLvR6D2gXgIG7xPGDhA EOSVB3KYVKaUsoH83eF1y/g//ixNLcGyZryxABXBQneR5EATkWTo0h46Z 4h59OjrDFdHW60BbBDa/52Jt13R0RTEK8CAiHEdeDOhY6hxhMs1mef/YU xQcb/mrJabdGH31HDT2yVEBUkt5cW//LoL5yne3liOzkDPS9czpM0QyRV w==; X-IronPort-AV: E=McAfee;i="6400,9594,10385"; a="341976546" X-IronPort-AV: E=Sophos;i="5.92,211,1650956400"; d="scan'208";a="341976546" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2022 19:26:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,211,1650956400"; d="scan'208";a="764694781" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by orsmga005.jf.intel.com with ESMTP; 21 Jun 2022 19:26:17 -0700 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 21 Jun 2022 19:26:17 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Tue, 21 Jun 2022 19:26:16 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Tue, 21 Jun 2022 19:26:16 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.48) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Tue, 21 Jun 2022 19:26:16 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F438i7pYX+DzjBjjQLll0FEOGhMkeb0TFmGhD0NbObEvT3QUqns05K6WGxALRx4eIRjeRs+PEJcMkMEf7cWfZFY7pvEFG4AWM6DjSgi94p/8b9l+sOw2fTyeiH0lFmRti8lEPvrXibL1c0WO04h4xGMF1M3177YHicUKBJwlPE1BOB9U7LjK6XfLH3p0x4W8xn5CA2o8pGWvRnyOyGAeMZsvbXGCe395UMgIX8PD0+f0FZVdkzG0zizu7RiQoT3E1bLt0SkG1M/9kVdcxnRwmgU1MBJFhlCnPcYBIrQxat0y9Il0ia88CqvHjiMqRNWRtjeNtxkXER+cIQWTQI66mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EsREgtZMFjeH15nFCZGsnWiUNavqUpqAq0kLq9SOBJk=; b=JvF8RzavXRznBrNZiIM5ziWhaF8bauJhBm53c4kaoDGmG1GgWTt7PLy6spKKjXXONlfynH3Sl1/oGcK7UH7ngBHV3Nyay9amGpOUvNEfD4+BFs6o4eATzZ8vd5lkmxYeq6Epi3ws8rtRIRFogg+VoGT1wQeSNAY7sqIQ4B3Kx5awlqfAVMChoXseByY7fFdJrvLdAlGIptwSy3M9oe6VQyAEGgHkVVLJoG9vCyvLzA9qcDu+PAk81pLgNC6ZNIdB5B3t9CZPC1H11lx4rDXX7+xV39jD/Bsbx5JOBMNj9i3bq0Vn6HsaNqRw7jFftsvUt6vXGz5fdJp/v9BOr240FQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from SA2PR11MB4906.namprd11.prod.outlook.com (2603:10b6:806:fa::7) by PH7PR11MB6524.namprd11.prod.outlook.com (2603:10b6:510:210::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.15; Wed, 22 Jun 2022 02:26:14 +0000 Received: from SA2PR11MB4906.namprd11.prod.outlook.com ([fe80::b0ae:808:85a2:913f]) by SA2PR11MB4906.namprd11.prod.outlook.com ([fe80::b0ae:808:85a2:913f%5]) with mapi id 15.20.5373.015; Wed, 22 Jun 2022 02:26:14 +0000 From: "Wang, YuanX" To: "Xia, Chenbo" , "maxime.coquelin@redhat.com" , "dev@dpdk.org" CC: "Hu, Jiayu" , "He, Xingguang" , "stable@dpdk.org" , "Ling, WeiX" Subject: RE: [PATCH v2] examples/vhost: fix retry logic on eth rx path Thread-Topic: [PATCH v2] examples/vhost: fix retry logic on eth rx path Thread-Index: AQHYghg/44Vhy1elAUWG5f1zm9VkSa1Z4y2AgADWJtA= Date: Wed, 22 Jun 2022 02:26:14 +0000 Message-ID: References: <20220518162505.1691401-1-yuanx.wang@intel.com> <20220617070144.710487-1-yuanx.wang@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fa8c732e-6361-4d89-47a1-08da53f6947f x-ms-traffictypediagnostic: PH7PR11MB6524:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: tF5dUNPCE3i6ENxPK3azhZSyJ0MS8gBy16+OO0OZQEz1ZI5dkzJL/ds4w+17GgMjRizUYYXzqAWL0xbigScdJk9HUn3PupRGSZTESjKxQQkYRxqOhlHOUTcqiipg/gvSbBynuBrY8YDB+8UitaFCp5BsiYRKjVn6180UbBCuZJzHFl1+K0X/YRAMQ66HpqEUcHL1jbsxGJEjmw2VBaxO7YMW4MGbSkrrURBtbAlIs3FSgTr9tgSpipVX2SqkK8XZxrhC1JP7VpPFLMMC8ufwSMICTGxblI6ZHLpvmFdCdak1qZdWtMjPecp9Om8DaX4CDUoe8WeddZBIQ/BC9OVsFo1vCs1Wx+FVq8kHK1EbxkXPX6gJxE6WigPti9EuJCmUqONcT5jTi8/Nal1fvs3O69hyeH5jWOa3kmGEOrlZE2yuIVPtUzDLZ2pGF7Sx1MjThrenS23xKg/jDkNlZEUSTNp4jpPxfiD59a48vpLgme7oKBfRzulYifHtvZRJQ6wbUeHM1iePm5MCxVOE88AEzn3mOYC076Vhx0ZoQOgO4EmWKaN6vTRNeO3Ycsy/iKt/0qiCjqW4RCWsc10+Cas4oqQFlAljYPZ6e98Knxq82Yt2+WanKwMDjiixsr/ocmRLjgwL/6yAkOuy8v0XtcQBK0r3LgdMENICoCzHxcYbVgFZxZdA4DzMBiFdD9bYMTbFhsEz5Oh8KcCiQayb3ir9vZ0vlqZWPUMucldsunhc4QLnV3M3ia0uwz6Tjglru9vt x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR11MB4906.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(39860400002)(396003)(376002)(366004)(136003)(346002)(8936002)(38100700002)(54906003)(33656002)(186003)(53546011)(83380400001)(86362001)(5660300002)(478600001)(76116006)(9686003)(316002)(66446008)(52536014)(122000001)(82960400001)(41300700001)(66556008)(26005)(4326008)(2906002)(38070700005)(55016003)(7696005)(6506007)(71200400001)(66476007)(8676002)(64756008)(107886003)(110136005)(66946007); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?4NgeELdG1iKbZy26wsfIxTJIBdHiIlV+91ToLZuvKjbjzdGV5JBJfJ64huhC?= =?us-ascii?Q?Mam2cESe9U8NuXHMclr5JTrUEHLoF6kWIpZgKXpxGa9g610LY//g+MLYdE9U?= =?us-ascii?Q?xjRAMLVrCwTDq4dtMCKk8aP2jr++Bq/be8SeykvjhEHadNZF4qzh7Ve8pJPi?= =?us-ascii?Q?szy1GnUiwrUU1BeQVCrlZjEHLOTVlAHKmEzn/jRCx9TYL1yOFRjOl259y5F0?= =?us-ascii?Q?vUztc77IfkEeq3nEi/bSYDt5glcaVbNLPSsaDSeH4kKwlQ+DooHfdTVea/TT?= =?us-ascii?Q?pQWqeyah93p9WhG6hvEeoyY2KKq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TBMFTG9/1fDeOz3jpLG3TWFd12cP8O4bDJYv5InOFp22qGxP3tOzZSCT?= =?us-ascii?Q?H1TYdaoJIlVpNGNb+j8FWopKwvlebX9IDU7tkmcHfE5epiX7E/tKQ8TW8DOP?= =?us-ascii?Q?7gWaOY3boEMr77YpX2DUcGwanSRGVWMt2ZZk6NvBJsn1we6KMIjMY9GaKWt2?= =?us-ascii?Q?tgZVSzdHs91Q5E37SjfRqAVd9KQPdbDC3LF2f/2g9Aa1ilG3oHYj6grTc/lg?= =?us-ascii?Q?HY3iYXTx6SrPQW7bB+0ezNHkGiAMV/4SARCRBNHpiQYs4Ey9W2mnYq4kfT21?= =?us-ascii?Q?toV2zvrWkBFse3QwCY1XgW1ETDdx9JODnESGHUzXqQ2WFEylxHYC9nLtQyJn?= =?us-ascii?Q?eiBCVblV+iRhdHBiuGA7EstRNr91krE4Qjv0Hobv?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA2PR11MB4906.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa8c732e-6361-4d89-47a1-08da53f6947f X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jun 2022 02:26:14.4463 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: OAUwcF+BjmssFIjj8XHl3fOZM3g3po+RVl8X8Y7Xcd364s8mhJ7sDRUhbj31XIZSE4WwsDnCw2V1VVugKZMIig== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6524 X-OriginatorOrg: intel.com 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 Hi Chenbo, > -----Original Message----- > From: Xia, Chenbo > Sent: Tuesday, June 21, 2022 9:35 PM > To: Wang, YuanX ; maxime.coquelin@redhat.com; > dev@dpdk.org > Cc: Hu, Jiayu ; He, Xingguang > ; stable@dpdk.org; Ling, WeiX > > Subject: RE: [PATCH v2] examples/vhost: fix retry logic on eth rx path >=20 > Hi Yuan, >=20 > > -----Original Message----- > > From: Wang, YuanX > > Sent: Friday, June 17, 2022 3:02 PM > > To: maxime.coquelin@redhat.com; Xia, Chenbo ; > > dev@dpdk.org > > Cc: Hu, Jiayu ; He, Xingguang > > ; Wang, YuanX ; > > stable@dpdk.org; Ling, WeiX > > Subject: [PATCH v2] examples/vhost: fix retry logic on eth rx path > > > > 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") > > Cc: stable@dpdk.org > > > > Signed-off-by: Yuan Wang > > Tested-by: Wei Ling > > --- > > V2: Rebase to 22.07 rc1. > > --- > > examples/vhost/main.c | 27 ++++++++++----------------- > > 1 file changed, 10 insertions(+), 17 deletions(-) > > > > diff --git a/examples/vhost/main.c b/examples/vhost/main.c index > > e7fee5aa1b..e7a84333ed 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,20 @@ 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 =3D vdev_queue_ops[vdev- > >vid].enqueue_pkt_burst(vdev, > > + VIRTIO_RXQ, pkts, rx_count); > > > > - for (retry =3D 0; retry < burst_rx_retry_num; retry++) { > > + /* Retry if necessary */ > > + if (enable_retry && unlikely(enqueue_count < rx_count)) { > > + uint32_t retry =3D 0; > > + > > + while (enqueue_count < rx_count && retry++ < > > burst_rx_retry_num) { > > rte_delay_us(burst_rx_delay_time); > > - if (rx_count <=3D rte_vhost_avail_entries(vdev->vid, > > - VIRTIO_RXQ)) > > - break; > > + enqueue_count +=3D vdev_queue_ops[vdev- > > >vid].enqueue_pkt_burst(vdev, > > + VIRTIO_RXQ, > pkts, > > rx_count); >=20 > Looking at the code again, it seems current logic will enqueue more than > rx_count packets and same packet may be sent multiple times as you are > enqueue multiple times but using the same mbuf pointer and rx_count. >=20 Thanks for pointing that out, I did miss the packet index. Will fix in the next version. Thanks, Yuan > Thanks, > Chenbo >=20 > > } > > } > > > > - enqueue_count =3D 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); > > -- > > 2.25.1