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 4E499A0545; Thu, 23 Jun 2022 04:57:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F06C34069D; Thu, 23 Jun 2022 04:57:35 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id C33BA4069C; Thu, 23 Jun 2022 04:57:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655953054; x=1687489054; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=bVfGzO67gO4IwU++6WVHwar235UOWkBCHKb2cdQ0CV4=; b=k3EPxxcNdWBab7vIkhCNLyD8D4D99Hew0WvGbsImvW/sJ1xmTM3HxzkA pYUOvJ7XyjdzdiSvVRkcxmsAyCSqzSttd8pRZOdxIcGM1545GgPXq+eXO x7UCDlhvrBuPf+fpUyuEtHyrn0JD4/JCNRvLUcUi71s3D+Yw3X+GSic4p YjEEofSOrTrt78MFnpHa1OX4jE7VI995tKOmfS1kAJza9wHdJDHDKNh+R 6dTmAlFHtHPdnqGD/5YH1yGVy0qf3k0BvUS+E78OxxCQrUH1e5CjKrwVl gj/pDSp8uu3PWOPao87qfZ83OKMl34onnxBGCu+dbzbXOtFc8y1A99A+4 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10386"; a="306066267" X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="306066267" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2022 19:57:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="914990032" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga005.fm.intel.com with ESMTP; 22 Jun 2022 19:57:10 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Wed, 22 Jun 2022 19:57:09 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Wed, 22 Jun 2022 19:57:09 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) 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; Wed, 22 Jun 2022 19:57:09 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SPmfTiDB5wTT+6bH2QiB0wF61EAJEctfC6uzqcDZAcsPTFtsgQP3wNaaiaTvVM0DI+nXHzOkasEUDYki+dhUUcEObFzm8Oj+WHOWVqAYEJNcN7unjdS7dVMKPjNH3NVUgDNaOSi/8p54JvNSpvGjDJDcQjFDk8e3jTkbbDFbd8I2i7zI9mUYKOTodo3ph/L2edGgIA+BQzpPlRUrdGIN52RlO52gQV+nWKI8SUbvoEILqSawztWHdEnxyEaYnV/LMLcVumdPcjeooj5Gyikm0nuiJEqwwh91rF1CJQsrOkPsZ8QUW5/07NLaSoK55cgedc1NgAHo1aSoSinwv+DDCw== 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=k8X4N4pTrpvFP/ENeaN+7oH3o8RTzcInIu86BRB+KDA=; b=dJZQmI/Apl1samWbyJn3s+P8GmK6FLinxaLbtHkrBV/eo5hsiC74Mj5hNSOCOXzetRf7VZ5/9dkCAHpCTPYa4bbT279rjHttBzDHlZBa1XbhIheFOo+RXgKBJSXuHC2egW39wJ8aLpdm9/ls8Nz4UbYU4auhlE1YReExGS9PXRj2zA1XE5VYw7V9/TaatSxIPRFx7n8OmoU82TXaRqnspDEwoJxdKOUPWN19s7Eu9VaQkn3d45KgELxfA1F5BcsQukZK3N0HBSheGNHaYQ1KAGU0tCyl9bklJnm+7xuexLxTW1/h5DgGTG7X52swu8y0wYA7+Y4/53Ygvi01bBxRmw== 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 SN6PR11MB3504.namprd11.prod.outlook.com (2603:10b6:805:d0::17) by SJ1PR11MB6299.namprd11.prod.outlook.com (2603:10b6:a03:456::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.22; Thu, 23 Jun 2022 02:57:02 +0000 Received: from SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::54a0:2dbc:18b7:2aa9]) by SN6PR11MB3504.namprd11.prod.outlook.com ([fe80::54a0:2dbc:18b7:2aa9%7]) with mapi id 15.20.5353.022; Thu, 23 Jun 2022 02:57:02 +0000 From: "Xia, Chenbo" To: "Wang, YuanX" , "maxime.coquelin@redhat.com" , "dev@dpdk.org" CC: "Hu, Jiayu" , "He, Xingguang" , "Jiang, Cheng1" , "stable@dpdk.org" , "Ling, WeiX" Subject: RE: [PATCH v4] examples/vhost: fix retry logic on eth rx path Thread-Topic: [PATCH v4] examples/vhost: fix retry logic on eth rx path Thread-Index: AQHYhhpL5hqiOf4MVUGkf7Un2afR261cS17w Date: Thu, 23 Jun 2022 02:57:02 +0000 Message-ID: References: <20220518162505.1691401-1-yuanx.wang@intel.com> <20220622092555.1149810-1-yuanx.wang@intel.com> In-Reply-To: <20220622092555.1149810-1-yuanx.wang@intel.com> Accept-Language: en-US, zh-CN 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: 210f98e7-25e2-421f-95b0-08da54c40c8f x-ms-traffictypediagnostic: SJ1PR11MB6299: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: y3QFWGMgrtKMbRWN3WvYaOAEvEc0UpjBHxNXdtxDV9sjh1mwAVifUELvBQk+TsYff8iQIoX+Ii/bCQ9zGVOvh+BDGBM/DtX0oA+TFGo3AcsOU11VUjqaaVlUjZ4uLulbjIYI0Ut8g0nseiuBrZaUUvb58h7NXwyqNuBUv4e67ExUISD3iOP1fCKTGGBwdZP0SHi5BhwHTDAbo4J5SWZJlBE1RvzOKDjbmyLiL0P6wPqjS37rwZcZSK/W8a8JkqKXvrCpP9moCZf4D61QBDlmxdm8a3CVv4gwnA4xcTEvcyDmZYLSRz3PkDu79IaDfDWg2tPnTIjowo1dXAf67lwj9OT/4UPcBAvCMGwmKlpOvZ/kxxwn/vcA3qvGW2Kc24aao/ZrthuZijgQAEp2kd8t3H/Ij9RiGYifsjRrFlwpMcVeiX8dMtog2DiLqv7isW6ZkfUWu+qVxdlesvAsgE+uQUkplIo5BNSPpQUeqWFcI/lilDxVjStmKgDTscX1NtRTpUx7p7rvV82CPZCiFDS1LDdNcwP0f+ca3BYoxI2Is7aoyoN4VrZVKpBy65dS3JDTbbPIm7vHQtEsRItsrBQKZvRvXRyN40VoI/Lz+e+Xdbxs8wb6eVXngOuJ1JuKCWFqhicW3WNKJ+exfRRKqOh4atfHDRnCxn+sk+Za5VFTW3KsgIJy86MWb2YFDxHc/BGu5wgOBFovd0zB9JueRGn9MB3c5srKqVKMySszjdkOsW8f4dOVOnuJ7jJX8oGRDcf9aWmevLWwuQRBENRTaSihAg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR11MB3504.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(136003)(376002)(396003)(346002)(366004)(39860400002)(6506007)(186003)(53546011)(64756008)(83380400001)(5660300002)(38100700002)(66556008)(26005)(122000001)(76116006)(7696005)(4326008)(66476007)(316002)(33656002)(8936002)(8676002)(71200400001)(66946007)(38070700005)(86362001)(54906003)(2906002)(55016003)(107886003)(82960400001)(478600001)(66446008)(9686003)(52536014)(110136005)(41300700001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?PvrjHnoXPj9JKfcw2XeQGSV0E8HbxSiQ8gGG5+kfq+z6vigW50953QiDI9Fp?= =?us-ascii?Q?vPHSTcwtKfJCEgaOge2kST/ts7iizGW9NW1MpCmZgHglf83e96WDdY5PV7Di?= =?us-ascii?Q?yxoyhZczrzZKaqew9h/dG3upwBXrBBZaqpiPXT9MLRNguj7f5KXH04w/nVI1?= =?us-ascii?Q?xIDtr1/LlrCCKqEXrP/PVhhkh9g3w/1CK3FA8MwNMgXEuFGxLsVqPzdc5e1Y?= =?us-ascii?Q?Nlx27bfJocLSznZIFAVtrIUVQGSVMiB8QDebnXJq4NDJW4D58VRen0sCq7gJ?= =?us-ascii?Q?y/UQCCVkPxrTqSFsCBDnUSD4N4qgA1LngCMv7rHp2plZAF5x/TdSFQP5WbuY?= =?us-ascii?Q?f5u0uamUQdtac2/0fwfDt6F9a8a5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Szjoy7a2yB41BP9/OwMeF3L4tdXvLbxvvXrUVhnZQbxjUH415KLuCv?= =?us-ascii?Q?VuvXPLiOfrxr6+FVidw3YtlZi7kp5As8MY/WK77VH2OubS6bLbbejis1HRme?= =?us-ascii?Q?2agxCnYGFQmlD2MH/IlWrU4dcCXjTAnYIFvFpVHe1j8t75X1vrXP/PSdek+i?= =?us-ascii?Q?Xgzr10G2h71SFoiJXrO3IuOYC4jKr8ZYUeOFeNT0Jnew8ngajBMZiD76HKv9?= =?us-ascii?Q?uWlSEAjvDFhjtFd1eow101JC6Xk4wQsQPt16L6xtvJfQPrU/mGYREnTBTpL/?= =?us-ascii?Q?v3ENPhPRHvVJ0cFo9qyWssJBzrJ6IamxUCcrNJXf+SPHF3rJzNWfoqpcm1nd?= =?us-ascii?Q?qsqERlKGDCfrEJNkQrMEpbvHZZJIgc78dRNbBnN3RaYAk6E4h4mzjV241qyp?= =?us-ascii?Q?9wES3vJNl5v8BgZ4Y6IY1RZ5xXHOwRJQVHfvTJS2sRCcAJNggZjW/VFqu7MB?= =?us-ascii?Q?maarI0zvGA=3D=3D?= 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: SN6PR11MB3504.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 210f98e7-25e2-421f-95b0-08da54c40c8f X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jun 2022 02:57:02.6937 (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: VIOmsEL6plDYwVNlIKbYyotxYHZ0K7+03Tahfw3lo4ZaGXocUjSuvhWf8FCafOzR41k5uebLd6V92xKSQkaMYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR11MB6299 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > -----Original Message----- > From: Wang, YuanX > Sent: Wednesday, June 22, 2022 5:26 PM > To: maxime.coquelin@redhat.com; Xia, Chenbo ; > dev@dpdk.org > Cc: Hu, Jiayu ; He, Xingguang ; > Jiang, Cheng1 ; Wang, YuanX ; > stable@dpdk.org; Ling, WeiX > Subject: [PATCH v4] examples/vhost: fix retry logic on eth rx path >=20 > 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. >=20 > This patch fix that by using the difference between tx/rx burst > as the retry condition. >=20 > Fixes: be800696c26e ("examples/vhost: use burst enqueue and dequeue from > lib") > Cc: stable@dpdk.org >=20 > Signed-off-by: Yuan Wang > Tested-by: Wei Ling Yuan & Wei Please make sure it's re-tested. Patch seems good to me. Reviewed-by: Chenbo Xia > --- > V4: Fix fiexs tag. > V3: Fix mbuf index. > V2: Rebase to 22.07 rc1. > --- > examples/vhost/main.c | 28 +++++++++++----------------- > 1 file changed, 11 insertions(+), 17 deletions(-) >=20 > 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; >=20 > - /* > - * 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); >=20 > - 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[enqueue_count], > + rx_count - enqueue_count); > } > } >=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