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 68C00A054D for ; Tue, 21 Jun 2022 15:34:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 610CD427F1; Tue, 21 Jun 2022 15:34:59 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 7BC8340151; Tue, 21 Jun 2022 15:34:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655818496; x=1687354496; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=5i+oHf+0gnYwsBRsVp1bseM6RZPLnc6mWP7FEh+iwEo=; b=OgHEIpQr29ZlK7+Uujzr9YyHKhyVEmxGYo6KONgGL6p5UPVldmxcmuC4 ocKeJnKEw3ma9Jh1Eu4S+QJq8AxhX6rxFfsBK0ZoOnV8HSqidrAa1P22V /7LOCCrucw1NPrJBzl6/beTYj74sKJ/JeX/jRZ17uR3fwzm2emGOB1HCC mwofD2v/ivK1H5jj6GYNVkb039lZ+SiJAt9gg8Vg3zKyW06Z7pJzFCpAT rhsEKWNxbmbPLloJvi5/qqgGEk87D35JwZd8G4O0HfEze/yMAYyOAx3OV fVqIgxC8FQWiquwVbc1dV/GUKz8EQJd2tN2sM1YUmiu95Fq8Cc3s+MJbm Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10384"; a="341802026" X-IronPort-AV: E=Sophos;i="5.92,209,1650956400"; d="scan'208";a="341802026" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jun 2022 06:34:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,209,1650956400"; d="scan'208";a="833577529" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by fmsmga006.fm.intel.com with ESMTP; 21 Jun 2022 06:34:55 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx604.amr.corp.intel.com (10.18.126.84) 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 06:34:53 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) 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 via Frontend Transport; Tue, 21 Jun 2022 06:34:53 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.174) 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 06:34:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gQ28nGCLO4XIO2H9zE3VWszYkwivbf+X/F5WFefZMoCiXOLCrg+uFsdjlcDdUN2vHPqhl4uTPR1ENbOm8CstLc98oxAzKBCLzw9OVAXvGVHbuvW1zA9g6R9cERvfh5juBFDuClshrkwBkxReQj85V9io3fOMkHBonAYXoFioIrXw8xA8QMqD2Gr2WrrWWRF/5cuDSV7eeduxfteasPRHzBDQuvGRu+3l5LXtN6kyw4iugj9452tgnay1AWaJNU1tOtc4NqXR3Wo+rHb0wfZ5zSMQXllvpj2VzE/B85DbGVgbTSn+oeg2vaQudb8qZ5ZzYZu7Me3xlFFu9iFnJ2J65A== 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=21rNgwixPke8yFA8Nk9OdQj2TbT6aPm8n4oN8DzXaks=; b=CtY+4n2jAgoAH08a6aFWvedtKzhKYFU4D8udL110ovQRIxXhTvoBZ7Kp4FYZc9fBUGKsHrA8ehyEb35sqoyJGZNGU0pzYzCgYGYrQderX6UN++eSWH2UDCTrTFtbs+Ny9THuT5j9nAp3A1zrh4Zplwm/DnUO0+O4jcgSvkMu7j9r/lTliplsu0kETskAEskUPvzdVz4RdhhrnVHk4yf9GUt6tPxYBRIwU8OsXSLkRGdlph+YNOQJT0NbQwckz3gpT+DFNdPLIrp7ooT5/bfyJe7jtd6fQ6aYaY6XBOnJdX2eaAEie4XWyXZif+i4vmuGzWOzVhvdQf90OtEGtJJkbA== 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 BN9PR11MB5465.namprd11.prod.outlook.com (2603:10b6:408:11e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.16; Tue, 21 Jun 2022 13:34:51 +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; Tue, 21 Jun 2022 13:34:51 +0000 From: "Xia, Chenbo" 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 Thread-Topic: [PATCH v2] examples/vhost: fix retry logic on eth rx path Thread-Index: AQHYghg/9+VePvzvrUS0sngGr1HSNK1Z4hrA Date: Tue, 21 Jun 2022 13:34:51 +0000 Message-ID: References: <20220518162505.1691401-1-yuanx.wang@intel.com> <20220617070144.710487-1-yuanx.wang@intel.com> In-Reply-To: <20220617070144.710487-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: 7f009959-e31f-4e2d-63f2-08da538ad189 x-ms-traffictypediagnostic: BN9PR11MB5465: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: 7JjcdBJbBywXoGeqFWMalv/wy09pB5UlKzVnqHWBu+vkcAIyL/5uoR3C+K7+4q9JYdQIa+QI5XJ8SjebeL653axL8+v9xs/YvQIaPyzMCBMM5rNPLPm+pnb80b0BhJMe7rFDXnV1s+5iMpvLnU45JUanbp2/qMWNpXE0+Abq7zFpqNaSWoqB2d82XgmCjzCf23QlDehBjFZcJKnjoC5rpKxqlFuNzBQwsGcLOJj35Asfl4FSanb3KPHrPXru5bF4NxhxlzTnIr74Hs+j4cpATT5gRQIWJtLUSdxUA8tSHIAf1yhguahNtvPNzzdTt88XERaphenjOGmJ6nStlCNpNQjvkdbsMu3PomS3l55iyOzvj6JBhg0zTnWdhgZYUSfKQ6ysUopyHaEH+UKaH97oFqKqyaGrCSeoexmDo96M2or3ii3HaE8cmyVlO+nPsOLZ0SbBs/3OpTYNaYQe47gR3KY/s3d7KrvylFZMEomKGvJtUVMI9srtEodw1uUqbFn9rMw/WUIL0fmBVgGwn8hKV3soYgm2Uy/4K6CJrtUcfqpBTGkAtiDbn/3OZ6w7kAhjyIMhaTeJLnwLGUhAh7RVNVIGZQoqZxHeVPwGyFGKbTcXRG9DP8xQrfPf5lmreloFdJX3o7DT7Ahboh42zXvzSjuUCx5+pLSO7bolcR51vN8AG8l6U4eCuigfgdAg+Ox8FCRnOepnp2gKrupYKm56iA== 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)(39860400002)(376002)(346002)(366004)(396003)(136003)(8936002)(5660300002)(33656002)(83380400001)(71200400001)(478600001)(6506007)(55016003)(26005)(186003)(38070700005)(52536014)(9686003)(107886003)(41300700001)(54906003)(110136005)(7696005)(66556008)(2906002)(8676002)(82960400001)(66476007)(4326008)(316002)(122000001)(53546011)(86362001)(66446008)(64756008)(66946007)(76116006)(38100700002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?UoZjXrvyRnYpeaVDStLGLSiMosivl6gXVnmgrIm6i1PF56gLNC+NWPygJ10f?= =?us-ascii?Q?fJsRM0rQsI7Bsb05d3piYCIwtWEZUFUO8xc8wP8CLUtD+/kuE5pVlm2HfVWu?= =?us-ascii?Q?U3U10PFSovCaXS/vtXayNR76Kwzqkr0BxXFZLPDMQb3+tweMeg4/xhKmTIZM?= =?us-ascii?Q?Zyd//3LQmYI0ZY+NkuxWwGIkfVRB8j8WIJfjDITq3kzzX0o9bavEj9jWyhd9?= =?us-ascii?Q?rAyxrIMYZZ8w+wCHf8qYJrmpKunRrDluvtUkFRrQmGp1ttvLozY5SxAgRBT6?= =?us-ascii?Q?cyDgGEmJSMJZVa4CxHSRUVbSGg2ELgNM+wY0lriglgTjFOBddf3o+QqrFH9B?= =?us-ascii?Q?yTOuQnZ5YkJLWfCtTXHPDgu/Eu9VZ/0S7h6vVkOunp/e2mTy61el7H5kE9nb?= =?us-ascii?Q?/Rxcyh22IUAhjDTtOgskpmvC+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?uner+ZyBr1Jug6vHHWABHbW3Io5DonwDVfpE8NjPF2dqyU4BTfih8haAs9sA?= =?us-ascii?Q?bM43OTdhYVoEiJksLXUBR5vweSyncZLaweZ6as+25huihZ32sYRCQxnETLF2?= =?us-ascii?Q?v0eT+saKPU91ppUb4Y9EjRs1rzsOSpI7HwLO4R52MDL5DlTA4oLoi7gfDPiq?= =?us-ascii?Q?omSto6p+KB2UeMI0z+cbrMR+yoiQ2Kk/7Trjao+YCrzrcoYEu9NAawIPAi/Y?= =?us-ascii?Q?fk9gv5p8wMVINbbwvjPUnUJyzM2wKs8o0wXG/KQgQTekkK2j1KHgwiFBXwFJ?= =?us-ascii?Q?2CJduwucuaGBkFX24pU1x5PmDivnOwWzmewzwoEbPb/UKN5dZaWkUE+Qxe+i?= =?us-ascii?Q?3+F+C48vycDKvvj1ZAMclXaC4Hbh550B9vffGnbRAF21J0qFa5ybgUJVvstl?= =?us-ascii?Q?ho7sfSxGgA=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: 7f009959-e31f-4e2d-63f2-08da538ad189 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jun 2022 13:34:51.2068 (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: /k6GsqiDt2w5stIuI0Kh+7c/+QwJWqRiKXCNhEMYq5TPNpjxugadvjpRnlDvZx8LjjOqZNhwFOEe4KNmVZ3tXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5465 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 Yuan, > -----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 >=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: 4ecf22e356de ("vhost: export device id as the interface to > applications") > Cc: stable@dpdk.org >=20 > 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(-) >=20 > 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; >=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, > rx_count); 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 multi= ple times but using the same mbuf pointer and rx_count. Thanks, Chenbo=20 > } > } >=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