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 E9EE6A0543; Mon, 20 Jun 2022 05:20:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C971B4067C; Mon, 20 Jun 2022 05:20:18 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 4388740150; Mon, 20 Jun 2022 05:20:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655695217; x=1687231217; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=/Zdc7Z3Y/i+gtnnJVCKLiw1ItADawopxZVxEWnc48vk=; b=ek4U+/LHe1CZzPBfUQRC+faViMuuylgihWt6OKyIbja7++oBb/NIEmFT KjczhRGvxuL5pqzfWAaa4OLZqAXIYnKIxRcl4JJnqr33QJm7nGlklncjE a/D7akuBIE1hiMnzQ8957Jne41c9Ga+/uaAV8lSagzzDrqYuKLYYgT+wd sw0JgJ4IBt/g9e9MoNKAIHE0qgqrXUWH7zrcVqqFxqhjHOMUnWTMC7Hu8 wLg/bZJqFVuiYcWY7v/RzfmtGO66B4YiGr3XiLs0ZjBY6+vA6vtjLyJz6 fqwGNa72niGSm7aXyRbn13TqNGXwYDWuqzJT5EHr3OKZVfi+UFch6qzk+ w==; X-IronPort-AV: E=McAfee;i="6400,9594,10380"; a="259611945" X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="259611945" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2022 20:20:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="714448722" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by orsmga004.jf.intel.com with ESMTP; 19 Jun 2022 20:20:14 -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; Sun, 19 Jun 2022 20:20:14 -0700 Received: from fmsmsx604.amr.corp.intel.com (10.18.126.84) 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; Sun, 19 Jun 2022 20:20:14 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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 via Frontend Transport; Sun, 19 Jun 2022 20:20:14 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.176) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Sun, 19 Jun 2022 20:20:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gku++NKER0MczxQHvyh0HYEb7qbT9ats6hWWU5h5w1hdzIAysgrPixsZokxhBaoeJWFyXZDRiQTsfw703lK6tI6Ar+fk9pL7E77UVN+u57/D9qA+OxGEwuMDUscLU4RiNdK0qiiOWXNKpdoaltDPlWq3Wd2AxP9CFdXhxv71DQadZHmoqPpXlxjv9YVib+QELxdBBU3AR9tVS2lamBW9Bl8efziq/2iWwMomwkgwBhyj26BI7UeWhutbdI7yLvhfz49G6LpdwrVFYFHehfDQGVbNcwDOOtyHu0DQT4MDGRaqYZtA06jgjX7h6WoXqZePE8k5ZpwqU9FrsTD4q72i4Q== 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=dH6MgHWWLtiDXv5EMb2aBAacBxiiYSTtKAfXa9EudFE=; b=lceleW8Qw39NfYihj40+7Cbtc7d44eEyC1YDQtiWMp0aURJpttcm7UCk7fzSgZiHHT0JktdcozgsDxZ6XR1nxbhFf8ulwJhsr1+L5rajsfxHg5yaEWtXh51/vumVUX/ycxYVfCD0t1gvXQom8Wjzl+pDMAwuCnYp2wRaQXziImJkozDg97niLE0sBsMb54Prc6dEg+/ow/LCf4Ce4jUMBk12m1CwUfIneGGWiCFBsiclxfpTDV3yuedLeqCDTEoxn3RT64Dzr3Iem9UuC2p1hgS1DiDKvKHH0JSYr011iJfDEcKSqcur3A2w49FAQKzt4iHYKiPcvrrhrPsSXybDYg== 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 MWHPR1101MB2110.namprd11.prod.outlook.com (2603:10b6:301:4f::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.15; Mon, 20 Jun 2022 03:20:10 +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.021; Mon, 20 Jun 2022 03:20:10 +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+VePvzvrUS0sngGr1HSNK1Xoz3w Date: Mon, 20 Jun 2022 03:20:10 +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: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.6.500.17 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: 19fae6fd-f9da-4e3a-3a0a-08da526bc88f x-ms-traffictypediagnostic: MWHPR1101MB2110: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: o+MCm41q9hL9InQOgn7Z5SmKKHRztpUGtbse9Y+cYgB6FB0AohMQSWrBoBRtX6hnuYwZRspMo5kHGtzRPAUPq1In9l2jXBnAmKeMeOp8EwdPKdeBoxurRmoEin2p8qmCm9upQWSuhmUUwFXn1eoS+wvmn2QIRadsQrK7Lc9hqY6PtV5W+Jt7HPk5zjBplabI241STG8Gl56DDd0fh4x0uobpp0Rw7WkX8vYb03oLWAEJcZijo6g53Ri8exJC6XBNEhNSVwhhDJP5NOHnZINKHGkfp34o3VYO5SLCoq4/Is6nL81uXDBbP5Njpjnj8KFp1LR9cBZI4DEW+bnwhW+/J4Tbagt0E115KvSPIPR5C1OOG8Eh/Iv4CwGAg+eyk/oY4+VXwLL6V/Y3bxkYZn3xbkkVKzMttxMiAmXCb4Dw6L/jnZc/CEkFERtAyWr2OuC9D8kx8BHOnVIrYJePaRypF0fJObFzuXcY7ueq2IkoQrwtl6ZhfAqSsMnKNwFRw0GnkghFREyi/frkhROjP1iSH6qXPUDtHN23CwrF/jcW3qYHP+tO5BBPgqoRpoAnuqwoTNmkg2o/4BRERUKiuQLgwnYB/fmm+o6oCcdR06OP0St1SCpseQgHlfmSFW7wB9THcLdBEQ/vSkL9zQNdIEDHAZz8lazHL5Ob4VLLRKMbJ/HEFlLD5jbDfu+j96mAjEFRC6GhWevyLFqtJOyTclSkJQ== 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)(366004)(122000001)(9686003)(498600001)(55016003)(82960400001)(110136005)(316002)(54906003)(7696005)(8936002)(26005)(33656002)(71200400001)(8676002)(6506007)(53546011)(83380400001)(64756008)(4326008)(86362001)(107886003)(66556008)(76116006)(66946007)(66446008)(186003)(66476007)(5660300002)(52536014)(2906002)(38070700005)(38100700002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?jwdJCfx+ehodaC5cyPHwEK9omQBUC78tvvHvlbcfXb0bza7vGs34xza9XLPf?= =?us-ascii?Q?Y7cMWqv/TmvEnTtE0JzSlPHl+3nN/WEXUKiRrjmPAYhtwjw7xhBenxA3pE6c?= =?us-ascii?Q?jSDWK4OMXntHFBD9bg9oNm0ckEkalkqF5oRIJYULkVFhU3doex7zPxnSf77s?= =?us-ascii?Q?4B7SSZ0IyIMt6nowXcbqTcDwA8HssMw8u84570RXvIQl5iM3pwlk6fz6kBV3?= =?us-ascii?Q?QkujIguhY0TNIjaDkF/x4FIFAxdSjzqD6O/uZhfXJLuCKVEWIjr/0/xzspWT?= =?us-ascii?Q?A1KcirLPYnXgrlCO9UW0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zs?= =?us-ascii?Q?K8Sy2QDg8tNxyF1zD8Cd09k9tbIzxnx5mI5lht+Q/JhIvimIJGTkuNsqyqwX?= =?us-ascii?Q?nKnlrQHV0d6BNsSk7ThN/6mIlMa2qtSIZA+Vsyl1reZFlOUcqgYGpAiqvg4H?= =?us-ascii?Q?0MBnZFbZhIr6pG/2+j7J6zMOy1hDwl/Gwy1Mc9gUMQpgCtVp2fth9FsDIZCT?= =?us-ascii?Q?4ji9GaBUVoq4akSNwxPx0ESKtTLmltDlSvpq48tQ29Z1gfyUMSSv6G0BM7GV?= =?us-ascii?Q?VOYDojZKiFxv66mhvT434x6m5qJbfjWTh5KK3E2hrfYxB4xhNdIn424q//MW?= =?us-ascii?Q?RFdKTENzJTdIedT8iQGte9OMUr612hGoScSkDYQMAQbCgps9JXaHrvjkETCX?= =?us-ascii?Q?Rv2wYj2stEmDGm7rOt5iswVH1A+MaKU7uWZgW98ctFmOeTpAFUPedV8nhHrg?= =?us-ascii?Q?CF1tvX/8qKct0dkzAh25gjbzpGwmPyPh9YWRK/QVfCTMXP89IzuWYSwGE0uT?= =?us-ascii?Q?axtoKVW6a1mbxhPDRs68p+S66iNObX+ltP/AOJmDwZLFKHb+/kdleeszkQtJ?= =?us-ascii?Q?LobuosN92Q=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: 19fae6fd-f9da-4e3a-3a0a-08da526bc88f X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jun 2022 03:20:10.5998 (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: 3YrQRVZp5ZRWny812rC689+uEUjfWm/AML+b+ZsqDVJUhWogulL1/j9qoHKC2jHCu8cljbH8MGVOcGFcVEFUPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1101MB2110 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: 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. Does it mean we don't need the API rte_vhost_avail_entries() anymore? Jiayu/Yuan/Maxime, what do you think? Thanks, Chenbo >=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); > } > } >=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