From patchwork Tue Apr 20 08:57:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Jiayu" X-Patchwork-Id: 91807 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 41A6BA0547; Tue, 20 Apr 2021 04:28:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F3A1C4159F; Tue, 20 Apr 2021 04:28:43 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 3D9C940688; Tue, 20 Apr 2021 04:28:39 +0200 (CEST) IronPort-SDR: dWoRo5oWjuCsHtThMt9WuaKPZIi4vtZSKEkcZ7/zVDhCBGSBT1A+7wl9ZEA1oKT0uF3VN7F8U7 Yvw6xokekG4Q== X-IronPort-AV: E=McAfee;i="6200,9189,9959"; a="256741029" X-IronPort-AV: E=Sophos;i="5.82,235,1613462400"; d="scan'208";a="256741029" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2021 19:28:38 -0700 IronPort-SDR: iTK1ZqsJdASwFR9eqBaawBS6FVGwEG/iGnpF0ZlBEGpx2EQo0WHJYWgUVYN1HUkUR7LbKk1ett rzskcsGYFQ6w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,235,1613462400"; d="scan'208";a="426739848" Received: from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.118.193]) by orsmga008.jf.intel.com with ESMTP; 19 Apr 2021 19:28:35 -0700 From: Jiayu Hu To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, yinan.wang@intel.com, sunil.pai.g@intel.com, cheng1.jiang@intel.com, jiayu.hu@intel.com, stable@dpdk.org Date: Tue, 20 Apr 2021 04:57:43 -0400 Message-Id: <1618909066-114980-2-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1618909066-114980-1-git-send-email-jiayu.hu@intel.com> References: <1617368642-131298-1-git-send-email-jiayu.hu@intel.com> <1618909066-114980-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH v3 1/4] vhost: fix uninitialized vhost queue 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" This patch allocates vhost queue by rte_zmalloc() to avoid undefined values. Fixes: a277c7159876 ("vhost: refactor code structure") Cc: stable@dpdk.org Signed-off-by: Jiayu Hu Reviewed-by: Maxime Coquelin Tested-by: Yinan Wang --- lib/librte_vhost/vhost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index a70fe01..ea38cf2 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -608,7 +608,7 @@ alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx) if (dev->virtqueue[i]) continue; - vq = rte_malloc(NULL, sizeof(struct vhost_virtqueue), 0); + vq = rte_zmalloc(NULL, sizeof(struct vhost_virtqueue), 0); if (vq == NULL) { VHOST_LOG_CONFIG(ERR, "Failed to allocate memory for vring:%u.\n", i); From patchwork Tue Apr 20 08:57:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Jiayu" X-Patchwork-Id: 91808 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DCF23A0547; Tue, 20 Apr 2021 04:28:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 373E1415A7; Tue, 20 Apr 2021 04:28:45 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 9C3EE4159D for ; Tue, 20 Apr 2021 04:28:40 +0200 (CEST) IronPort-SDR: k7lTwC8AjHN/jGQ4uMImwsSh04Rtd7vdjujZ2elkxAekpoB6tODNFO7sHXlz9S96jj+CjpMvkW BI0KdQaVlZiA== X-IronPort-AV: E=McAfee;i="6200,9189,9959"; a="256741032" X-IronPort-AV: E=Sophos;i="5.82,235,1613462400"; d="scan'208";a="256741032" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2021 19:28:40 -0700 IronPort-SDR: 7ozsHcX8t2kP+P2M8+k+GYJzI3GqXW/XnP0xjw2IgjVfLODIqNCfIDqRnCwHoAwvo8Hoh3Eh3b Apt6k0MJTvyg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,235,1613462400"; d="scan'208";a="426739861" Received: from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.118.193]) by orsmga008.jf.intel.com with ESMTP; 19 Apr 2021 19:28:38 -0700 From: Jiayu Hu To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, yinan.wang@intel.com, sunil.pai.g@intel.com, cheng1.jiang@intel.com, jiayu.hu@intel.com Date: Tue, 20 Apr 2021 04:57:44 -0400 Message-Id: <1618909066-114980-3-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1618909066-114980-1-git-send-email-jiayu.hu@intel.com> References: <1617368642-131298-1-git-send-email-jiayu.hu@intel.com> <1618909066-114980-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH v3 2/4] vhost: remove unnecessary free 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" This patch removes unnecessary rte_free() for async_pkts_info and async_descs_split. Signed-off-by: Jiayu Hu Reviewed-by: Maxime Coquelin Tested-by: Yinan Wang --- lib/librte_vhost/vhost_user.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index cdd46a0..fa8929f 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -2013,13 +2013,6 @@ vhost_user_get_vring_base(struct virtio_net **pdev, } else { rte_free(vq->shadow_used_split); vq->shadow_used_split = NULL; - - if (vq->async_pkts_info) - rte_free(vq->async_pkts_info); - if (vq->async_descs_split) - rte_free(vq->async_descs_split); - vq->async_pkts_info = NULL; - vq->async_descs_split = NULL; } rte_free(vq->batch_copy_elems); From patchwork Tue Apr 20 08:57:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Jiayu" X-Patchwork-Id: 91809 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5B967A0547; Tue, 20 Apr 2021 04:28:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5A798415AD; Tue, 20 Apr 2021 04:28:51 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 290F0415A3; Tue, 20 Apr 2021 04:28:43 +0200 (CEST) IronPort-SDR: HMmLv84y+fe1rUpVZYai6DDzBd950o6xk7pxbquha0yL33vvOoljqBC/kmHFktii/BGehj2AC2 u6jgZGlNyj6Q== X-IronPort-AV: E=McAfee;i="6200,9189,9959"; a="256741038" X-IronPort-AV: E=Sophos;i="5.82,235,1613462400"; d="scan'208";a="256741038" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2021 19:28:42 -0700 IronPort-SDR: x58qikL7eLq0suMgFJxfPSI6VLHAlj7Ki3KlnSGNjMUm3Xd1bbZwuzaxgEWNnmcOnGw28iEPQ4 q7QfHoKdilfA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,235,1613462400"; d="scan'208";a="426739879" Received: from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.118.193]) by orsmga008.jf.intel.com with ESMTP; 19 Apr 2021 19:28:40 -0700 From: Jiayu Hu To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, yinan.wang@intel.com, sunil.pai.g@intel.com, cheng1.jiang@intel.com, jiayu.hu@intel.com, stable@dpdk.org Date: Tue, 20 Apr 2021 04:57:45 -0400 Message-Id: <1618909066-114980-4-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1618909066-114980-1-git-send-email-jiayu.hu@intel.com> References: <1617368642-131298-1-git-send-email-jiayu.hu@intel.com> <1618909066-114980-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH v3 3/4] vhost: fix unnecessary vring_state_changed call 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" When VHOST_USER_F_PROTOCOL_FEATURES is not negotiated, there is no need for vhost_user_set_vring_kick() to notify the application of vring enabled, as vhost_user_msg_handler() also notifies the application. This patch is to remove unnecessary vring_state_changed() call. Fixes: 966027b4b3a3 ("vhost: fix silent queue enabling with legacy guests") Cc: stable@dpdk.org Signed-off-by: Jiayu Hu Tested-by: Yinan Wang Reviewed-by: Maxime Coquelin --- lib/librte_vhost/vhost_user.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index fa8929f..611ff20 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1922,9 +1922,6 @@ vhost_user_set_vring_kick(struct virtio_net **pdev, struct VhostUserMsg *msg, */ if (!(dev->features & (1ULL << VHOST_USER_F_PROTOCOL_FEATURES))) { vq->enabled = true; - if (dev->notify_ops->vring_state_changed) - dev->notify_ops->vring_state_changed( - dev->vid, file.index, 1); } if (vq->ready) { From patchwork Tue Apr 20 08:57:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Jiayu" X-Patchwork-Id: 91810 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 22D8CA0547; Tue, 20 Apr 2021 04:29:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9C719415B5; Tue, 20 Apr 2021 04:28:52 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 288FA415AC for ; Tue, 20 Apr 2021 04:28:46 +0200 (CEST) IronPort-SDR: n+4rqf9B/V2ady6e/j5Z0pH5L2QCbkn39cEtoh7jYGZEus9fuOrF6OnKxwEpTe/6zm2XRNRAm4 fpPeKUxTYWyA== X-IronPort-AV: E=McAfee;i="6200,9189,9959"; a="256741041" X-IronPort-AV: E=Sophos;i="5.82,235,1613462400"; d="scan'208";a="256741041" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2021 19:28:45 -0700 IronPort-SDR: swDUt1XADf9srBLTxLc6DwqGtvgkZrC/Ak/RrDOSh3JWAajOqBedhjIV09PMozEogaAtRwTSc/ BfT+Bpc8IKLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,235,1613462400"; d="scan'208";a="426739893" Received: from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.118.193]) by orsmga008.jf.intel.com with ESMTP; 19 Apr 2021 19:28:43 -0700 From: Jiayu Hu To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, yinan.wang@intel.com, sunil.pai.g@intel.com, cheng1.jiang@intel.com, jiayu.hu@intel.com Date: Tue, 20 Apr 2021 04:57:46 -0400 Message-Id: <1618909066-114980-5-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1618909066-114980-1-git-send-email-jiayu.hu@intel.com> References: <1617368642-131298-1-git-send-email-jiayu.hu@intel.com> <1618909066-114980-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH v3 4/4] doc: update async vhost register/unregister 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" This patch is to update programmer guide for register/unregister copy devices in vhost. Signed-off-by: Jiayu Hu Reviewed-by: Maxime Coquelin --- doc/guides/prog_guide/vhost_lib.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst index dc29229..7afa351 100644 --- a/doc/guides/prog_guide/vhost_lib.rst +++ b/doc/guides/prog_guide/vhost_lib.rst @@ -208,9 +208,9 @@ The following is an overview of some key Vhost API functions: * ``rte_vhost_async_channel_register(vid, queue_id, features, ops)`` - Register a vhost queue with async copy device channel. - Following device ``features`` must be specified together with the - registration: + Register a vhost queue with async copy device channel after vring + is enabled. Following device ``features`` must be specified together + with the registration: * ``async_inorder`` @@ -244,6 +244,14 @@ The following is an overview of some key Vhost API functions: * ``rte_vhost_async_channel_unregister(vid, queue_id)`` Unregister the async copy device channel from a vhost queue. + Unregistration will fail, if the vhost queue has in-flight + packets that are not completed. + + Unregister async copy devices in vring_state_changed() may + fail, as this API tries to acquire the spinlock of vhost + queue. The recommended way is to unregister async copy + devices for all vhost queues in destroy_device(), when a + virtio device is paused or shut down. * ``rte_vhost_submit_enqueue_burst(vid, queue_id, pkts, count, comp_pkts, comp_count)``