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 A88E0A0C47; Tue, 12 Oct 2021 08:05:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 443864067C; Tue, 12 Oct 2021 08:05:50 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mails.dpdk.org (Postfix) with ESMTP id 1534140150 for ; Tue, 12 Oct 2021 08:05:48 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10134"; a="226950999" X-IronPort-AV: E=Sophos;i="5.85,366,1624345200"; d="scan'208";a="226950999" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2021 23:05:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,366,1624345200"; d="scan'208";a="562502803" Received: from irsmsx602.ger.corp.intel.com ([163.33.146.8]) by FMSMGA003.fm.intel.com with ESMTP; 11 Oct 2021 23:05:47 -0700 Received: from shsmsx606.ccr.corp.intel.com (10.109.6.216) by irsmsx602.ger.corp.intel.com (163.33.146.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Tue, 12 Oct 2021 07:05:45 +0100 Received: from shsmsx606.ccr.corp.intel.com ([10.109.6.216]) by SHSMSX606.ccr.corp.intel.com ([10.109.6.216]) with mapi id 15.01.2242.012; Tue, 12 Oct 2021 14:05:42 +0800 From: "Hu, Jiayu" To: Maxime Coquelin , "dev@dpdk.org" , "Xia, Chenbo" , "Wang, YuanX" , "Ma, WenwuX" , "Richardson, Bruce" , "Mcnamara, John" Thread-Topic: [RFC 08/14] vhost: improve IO vector logic Thread-Index: AQHXu8iQgo7jZrXxLk+ctwT0LRsrLKvO33AA Date: Tue, 12 Oct 2021 06:05:42 +0000 Message-ID: References: <20211007220013.355530-1-maxime.coquelin@redhat.com> <20211007220013.355530-9-maxime.coquelin@redhat.com> In-Reply-To: <20211007220013.355530-9-maxime.coquelin@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.6.200.16 dlp-product: dlpe-windows x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [RFC 08/14] vhost: improve IO vector logic 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 Sender: "dev" Hi, > -----Original Message----- > From: Maxime Coquelin > Sent: Friday, October 8, 2021 6:00 AM > To: dev@dpdk.org; Xia, Chenbo ; Hu, Jiayu > ; Wang, YuanX ; Ma, > WenwuX ; Richardson, Bruce > ; Mcnamara, John > > Cc: Maxime Coquelin > Subject: [RFC 08/14] vhost: improve IO vector logic >=20 > IO vectors and their iterators arrays were part of the async metadata but= not > their indexes. >=20 > In order to makes this more consistent, the patch adds the indexes to the > async metadata. Doing that, we can avoid triggering DMA transfer within t= he > loop as it IO vector index overflow is now prevented in the > async_mbuf_to_desc() function. >=20 > Note that previous detection mechanism was broken since the overflow > already happened when detected, so OOB memory access would already > have happened. >=20 > With this changes done, virtio_dev_rx_async_submit_split() > and virtio_dev_rx_async_submit_packed() can be further simplified. >=20 > Signed-off-by: Maxime Coquelin > --- > lib/vhost/vhost.h | 2 + > lib/vhost/virtio_net.c | 296 +++++++++++++++++++---------------------- > 2 files changed, 136 insertions(+), 162 deletions(-) >=20 > diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h index > dae9a1ac2d..812d4c55a5 100644 > --- a/lib/vhost/vhost.h > +++ b/lib/vhost/vhost.h > @@ -134,6 +134,8 @@ struct vhost_async { >=20 > struct rte_vhost_iov_iter iov_iter[VHOST_MAX_ASYNC_IT]; > struct rte_vhost_iovec iovec[VHOST_MAX_ASYNC_VEC]; > + uint16_t iter_idx; > + uint16_t iovec_idx; >=20 > /* data transfer status */ > struct async_inflight_info *pkts_info; diff --git a/lib/vhost/virtio_ne= t.c > b/lib/vhost/virtio_net.c index ae7dded979..5ce4c14a73 100644 > --- a/lib/vhost/virtio_net.c > +++ b/lib/vhost/virtio_net.c > @@ -924,33 +924,91 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct > vhost_virtqueue *vq, > return error; > } >=20 > +static __rte_always_inline int > +async_iter_initialize(struct vhost_async *async) { > + struct rte_vhost_iov_iter *iter; > + > + if (unlikely(async->iter_idx >=3D VHOST_MAX_ASYNC_IT)) { > + VHOST_LOG_DATA(ERR, "no more async iterators > available\n"); > + return -1; > + } async->iter_idx will not exceed VHOST_MAX_ASYNC_IT, as virtio_dev_rx makes sure the number of packets to enqueue is less than or equal to MAX_PKT_BURST and it is the same as VHOST_MAX_ASYNC_IT. > + > + if (unlikely(async->iovec_idx >=3D VHOST_MAX_ASYNC_VEC)) { > + VHOST_LOG_DATA(ERR, "no more async iovec available\n"); > + return -1; > + } > + > + > + iter =3D async->iov_iter + async->iter_idx; > + iter->iov =3D async->iovec + async->iovec_idx; > + iter->nr_segs =3D 0; > + > + return 0; > +} > + > +static __rte_always_inline int > +async_iter_add_iovec(struct vhost_async *async, void *src, void *dst, > +size_t len) { > + struct rte_vhost_iov_iter *iter; > + struct rte_vhost_iovec *iovec; > + > + if (unlikely(async->iovec_idx >=3D VHOST_MAX_ASYNC_VEC)) { > + VHOST_LOG_DATA(ERR, "no more async iovec available\n"); > + return -1; > + } > + > + iter =3D async->iov_iter + async->iter_idx; > + iovec =3D async->iovec + async->iovec_idx; async->iovec_idx is never gotten increased. Thanks, Jiayu