From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 18F2FA0528; Fri, 17 Jul 2020 05:21:08 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E7C4F1BED1; Fri, 17 Jul 2020 05:21:07 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 72E9A1BEC0 for ; Fri, 17 Jul 2020 05:21:06 +0200 (CEST) IronPort-SDR: iiPQqvALix6V2WZ46C7N6KZNjdIFWElGhVJzDqDLTLfflLCB8cLT1Z0pr0ZkQqegmu+wlzpZmb ve9aDTyjjBUg== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="147040983" X-IronPort-AV: E=Sophos;i="5.75,361,1589266800"; d="scan'208";a="147040983" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 20:21:05 -0700 IronPort-SDR: J2SV6xwrTnZslt4OLny/QuOGilwkYO7q7QxujG84eTfYMhaH8aAjcljeWSP5ifpLk6lpNmh9IZ I/GHtzo7krbg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,361,1589266800"; d="scan'208";a="300439187" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by orsmga002.jf.intel.com with ESMTP; 16 Jul 2020 20:21:05 -0700 Received: from orsmsx122.amr.corp.intel.com (10.22.225.227) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jul 2020 20:21:04 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by ORSMSX122.amr.corp.intel.com (10.22.225.227) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jul 2020 20:21:04 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.108) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 16 Jul 2020 20:21:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UhnZ0/PfKkFNIstI4YJiStZR55BJAfdz8g6wdMKS4SN9qlsq82NZ4kfgivmyqPkFu9RpMeiBWf5GNf1iNH8F0le4ZTY6ek8J7p6NLq/Mx8sAm4FumqdoSKLrLrWlmQFhB+umQMdOmSX8bdoq4sqS48lrGFNC75sbOOV/7WTQL8MyEjUR8G6KY7/X/HoWWNEuPUh56GAXnDQfzuyzk+6np/M47+1zT0Bq5348Gny5nBRV50kEOMt/S7z+GOtNC6OTr8HOQPAk9Mj7nk5C/N4yBppAvaCVtuvOT0GcwDuJNEO0/Py+BjoEH1fq1plhf1E5Teaq9nEhS6SYEgSzUmLeKA== 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-SenderADCheck; bh=FK1v/VLdqRa2LBcBe+dsVgP1stNtgZ9aXBs3ZBlI2B8=; b=kSglsVvDmNFVT0SRy0RuqgrYtAHNbW7dwMZdULW55x77V8Pyha4JGBhwLLgT+2wyj1G73MOF+et1V9FRysXwHqp07dDX1r9QZILe5A8WnnAQTnuVU2QQFlSm7x3be+hFMDcpNi5b+kom+zrjTqhn39HHM+YChe51u/xtdm79v9JunQqsfdPr7s80dC7phY9CAs74OZlAPQYYa8eK2ey3WW00lMrf/NAzzTul7nNAg10amL5Unw03pYwpLl+rZ3J5BIqzUIqiqq0kvChTI9U1+QB8+ZIfFV6RA1u8OTHgBK7m2OGRGgtUwwymyjIUSf/Q4p1Lbnhz1NWLvgVrJsdvfw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FK1v/VLdqRa2LBcBe+dsVgP1stNtgZ9aXBs3ZBlI2B8=; b=EyO727/OnwizJs9JY4hMUPbZEseKLobtsHsVY01BmkY1/APQIae63/M0m1s17W2wES6YiM2oaeU3bSJD8a7k5X8akTbvr6A5/VPznaY3srm8Fx9sjWN04V6U5nd+0Ex5Z1zySc37anJrtAkaXAY6OsZzX6E4PvjCbYCK5Cx+vNc= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB3949.namprd11.prod.outlook.com (2603:10b6:208:138::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.22; Fri, 17 Jul 2020 03:21:02 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::7cde:8326:5010:c47e]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::7cde:8326:5010:c47e%7]) with mapi id 15.20.3174.025; Fri, 17 Jul 2020 03:21:02 +0000 From: "Xia, Chenbo" To: "Fu, Patrick" , "dev@dpdk.org" , "maxime.coquelin@redhat.com" CC: "Wang, Yinan" Thread-Topic: [PATCH v2] vhost: support async copy free segmentations Thread-Index: AQHWWpmCTUK1Kx7QJkWuV80lu+iBU6kLHUQQ Date: Fri, 17 Jul 2020 03:21:02 +0000 Message-ID: References: <20200715074650.2375332-1-patrick.fu@intel.com> <20200715111520.2755307-1-patrick.fu@intel.com> In-Reply-To: <20200715111520.2755307-1-patrick.fu@intel.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.217] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 22a0b6b0-33dc-40a1-1ee1-08d82a006f5b x-ms-traffictypediagnostic: MN2PR11MB3949: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: raQIlwkLdmwoQXxNuiXx/pCty33HerWxhpbEc7NKf4k5dsBNN72q2mjG9Uc7/Di4GOTdMLlIPzKWkQyBBBzBgFaMkkDDIeHZsZKzXn1uSLXCrVLsiPPoImenNBF/5nt02zMoA/I5C+i1Ad+XZFjtxFyHzjXiJKY7fdlXDrv+Kd7uKgx7YC4hpeMI4JuKyGaB8oelz/DFESIdVWFrJsYwEJS1QDilOPDGVhRoC/WURFqUxU0Y2LSZ3F9r3oG2my4e7T2XmsAAbtmGOu7hqydX4YTxMnaYXNRBzCm2yKhQlxC0VW3023sdlqiFQOVr4phK x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR11MB4063.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(136003)(396003)(346002)(376002)(366004)(5660300002)(107886003)(2906002)(9686003)(8936002)(6506007)(55016002)(8676002)(66556008)(53546011)(83380400001)(52536014)(33656002)(66476007)(76116006)(66446008)(26005)(7696005)(66946007)(316002)(478600001)(110136005)(64756008)(86362001)(186003)(4326008)(71200400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: sMP41tcxV1+XS0qdXjOjVVNvgDmv8Xp4mSV5oy4x1yhNN1HqS6+xIZfhHNRQ2q22xefznUlYOQiIivCn6xMATT8e7HK6TPhUK0HR1BD3zafcdR1nxUPyLp0ajyY7nCLxwMCPI2K5mlmfdUC6wpOt5S1DNvroDg86Kat62HZm7A+ASgGBj6V1JqwvavVxXm6AQy/ll1eVzuZi4ufuOHPU2VnLky2uka0865v8/tFhJsynpR5Pv84KR4jMuUBXin8PyLAuHsvizkthfhBjVbPUPsuiMONXyDkJDr8OkoQ9KNFiDDjUupeh/WfPqnn+cFg/yLshdhgP1JCg0wdD5GvCMacqqTgh0nS8b4+zbGA4a04qO2z6W5uSJv/EDthEmTQ0keQDl5D7XFr+3KHrkmhbqEq2F8jd79pfu3/CWn3wWHxjYuuY88SmG1EMo+MILn5CT6S+oo988bV1p0XCMIJbiQbNzQK3j+F+BBOdKYoY6wvhw8CjC5BDJd5pp0+wgHkS 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: MN2PR11MB4063.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22a0b6b0-33dc-40a1-1ee1-08d82a006f5b X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jul 2020 03:21:02.7765 (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: iJZPAXaxDX7dUUIDaG9yqCvXbp7rWRC6aCL10XPUlwkzF4LHhPXsdoWxmrUkc+qr6uubbpp6IZ4Yd7HdGWldXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3949 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v2] vhost: support async copy free segmentations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Fu, Patrick > Sent: Wednesday, July 15, 2020 7:15 PM > To: dev@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo > > Cc: Fu, Patrick ; Wang, Yinan > Subject: [PATCH v2] vhost: support async copy free segmentations >=20 > From: Patrick Fu >=20 > Vhost async enqueue assumes that all async copies should break at packet > boundary. i.e. if a packet is splited into multiple copy segments, the as= ync engine > should always report copy completion when entire packet is finished. This= patch > removes the assumption. >=20 > Fixes: cd6760da1076 ("vhost: introduce async enqueue for split ring") >=20 > Signed-off-by: Patrick Fu > --- > v2: > - fix an issue that can stuck async poll when packets buffer is full > - rename a local variable to better reflect its usage >=20 > lib/librte_vhost/vhost.h | 3 +++ > lib/librte_vhost/virtio_net.c | 17 ++++++++++++----- > 2 files changed, 15 insertions(+), 5 deletions(-) >=20 > diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index > 8c01cee42..0f7212f88 100644 > --- a/lib/librte_vhost/vhost.h > +++ b/lib/librte_vhost/vhost.h > @@ -46,6 +46,8 @@ >=20 > #define MAX_PKT_BURST 32 >=20 > +#define ASYNC_MAX_POLL_SEG 255 > + > #define VHOST_MAX_ASYNC_IT (MAX_PKT_BURST * 2) #define > VHOST_MAX_ASYNC_VEC (BUF_VECTOR_MAX * 2) >=20 > @@ -225,6 +227,7 @@ struct vhost_virtqueue { > uint64_t *async_pending_info; > uint16_t async_pkts_idx; > uint16_t async_pkts_inflight_n; > + uint16_t async_last_seg_n; >=20 > /* vq async features */ > bool async_inorder; > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.= c index > 1d0be3dd4..17808ab29 100644 > --- a/lib/librte_vhost/virtio_net.c > +++ b/lib/librte_vhost/virtio_net.c > @@ -1633,6 +1633,7 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, > uint16_t queue_id, > struct vhost_virtqueue *vq; > uint16_t n_pkts_cpl, n_pkts_put =3D 0, n_descs =3D 0; > uint16_t start_idx, pkts_idx, vq_size; > + uint16_t n_inflight; > uint64_t *async_pending_info; >=20 > VHOST_LOG_DATA(DEBUG, "(%d) %s\n", dev->vid, __func__); @@ - > 1646,28 +1647,32 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, > uint16_t queue_id, >=20 > rte_spinlock_lock(&vq->access_lock); >=20 > + n_inflight =3D vq->async_pkts_inflight_n; > pkts_idx =3D vq->async_pkts_idx; > async_pending_info =3D vq->async_pending_info; > vq_size =3D vq->size; > start_idx =3D virtio_dev_rx_async_get_info_idx(pkts_idx, > vq_size, vq->async_pkts_inflight_n); >=20 > - n_pkts_cpl =3D > - vq->async_ops.check_completed_copies(vid, queue_id, 0, > count); > + n_pkts_cpl =3D vq->async_ops.check_completed_copies(vid, queue_id, > + 0, ASYNC_MAX_POLL_SEG - vq->async_last_seg_n) + > + vq->async_last_seg_n; >=20 > rte_smp_wmb(); >=20 > - while (likely(((start_idx + n_pkts_put) & (vq_size - 1)) !=3D pkts_idx)= ) { > + while (likely((n_pkts_put < count) && n_inflight)) { > uint64_t info =3D async_pending_info[ > (start_idx + n_pkts_put) & (vq_size - 1)]; > uint64_t n_segs; > n_pkts_put++; > + n_inflight--; > n_descs +=3D info & ASYNC_PENDING_INFO_N_MSK; > n_segs =3D info >> ASYNC_PENDING_INFO_N_SFT; >=20 > if (n_segs) { > - if (!n_pkts_cpl || n_pkts_cpl < n_segs) { > + if (unlikely(n_pkts_cpl < n_segs)) { > n_pkts_put--; > + n_inflight++; > n_descs -=3D info & > ASYNC_PENDING_INFO_N_MSK; > if (n_pkts_cpl) { > async_pending_info[ > @@ -1684,8 +1689,10 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, > uint16_t queue_id, > } > } >=20 > + vq->async_last_seg_n =3D n_pkts_cpl; > + > if (n_pkts_put) { > - vq->async_pkts_inflight_n -=3D n_pkts_put; > + vq->async_pkts_inflight_n =3D n_inflight; > __atomic_add_fetch(&vq->used->idx, n_descs, > __ATOMIC_RELEASE); >=20 > vhost_vring_call_split(dev, vq); > -- > 2.18.4 Reviewed-by: Chenbo Xia