From patchwork Wed Mar 17 12:56:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Jiayu" X-Patchwork-Id: 89325 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 EC612A00C2; Wed, 17 Mar 2021 07:26:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 57641242AFA; Wed, 17 Mar 2021 07:26:28 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 1C6FE40689 for ; Wed, 17 Mar 2021 07:26:25 +0100 (CET) IronPort-SDR: 0Cji/DYhy1+r11cpsOUAM5fGrBE8i0XM6P1BjR/BhZLfcB41JJLpvk1i5MymSFVHRsIKEfyRbT GN9oIpZNAUXQ== X-IronPort-AV: E=McAfee;i="6000,8403,9925"; a="186041209" X-IronPort-AV: E=Sophos;i="5.81,255,1610438400"; d="scan'208";a="186041209" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2021 23:26:25 -0700 IronPort-SDR: FvWmRdYZW71PO7fHq6Xmwf8kMSLLEvYyzp6ebqONjxTZ5INprHcEsXgZ52xc9jiQfzye44xWmW uFeiohp2h6bw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,255,1610438400"; d="scan'208";a="433282863" Received: from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.118.193]) by fmsmga004.fm.intel.com with ESMTP; 16 Mar 2021 23:26:23 -0700 From: Jiayu Hu To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, yinan.wang@intel.com, cheng1.jiang@intel.com, sunil.pai.g@intel.com, Jiayu Hu Date: Wed, 17 Mar 2021 08:56:10 -0400 Message-Id: <1615985773-406787-2-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1615985773-406787-1-git-send-email-jiayu.hu@intel.com> References: <1615985773-406787-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH 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: 8acd7c213353 ("vhost: fix virtqueues metadata allocation") Signed-off-by: Jiayu Hu --- 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 52ab93d..f6fd001 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -598,7 +598,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 Wed Mar 17 12:56:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Jiayu" X-Patchwork-Id: 89326 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 BDB2BA00C2; Wed, 17 Mar 2021 07:26:38 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8408A242B01; Wed, 17 Mar 2021 07:26:29 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 2DC97242AF7 for ; Wed, 17 Mar 2021 07:26:28 +0100 (CET) IronPort-SDR: 7c2mwnBw3wwRZ8bp625hIOPY13vHE9VoMdDNbFIsquRs1SrJNiYBMfoU5VDOvMrNCb1KTr6NRT Zu8YuNjvt/4w== X-IronPort-AV: E=McAfee;i="6000,8403,9925"; a="186041212" X-IronPort-AV: E=Sophos;i="5.81,255,1610438400"; d="scan'208";a="186041212" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2021 23:26:27 -0700 IronPort-SDR: wmRlKr8CfVeQzvcczNWeJ1I6kZQbgEPj9S7mXGk6Nij7PM3ZgDyiY13uHjQusgrHw3S7SvVcoi 7Vro1BfILQ2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,255,1610438400"; d="scan'208";a="433282882" Received: from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.118.193]) by fmsmga004.fm.intel.com with ESMTP; 16 Mar 2021 23:26:26 -0700 From: Jiayu Hu To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, yinan.wang@intel.com, cheng1.jiang@intel.com, sunil.pai.g@intel.com, Jiayu Hu Date: Wed, 17 Mar 2021 08:56:11 -0400 Message-Id: <1615985773-406787-3-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1615985773-406787-1-git-send-email-jiayu.hu@intel.com> References: <1615985773-406787-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH 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 --- 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 a60bb94..399675c 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -2010,13 +2010,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 Wed Mar 17 12:56:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Jiayu" X-Patchwork-Id: 89327 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 8963EA00C2; Wed, 17 Mar 2021 07:26:45 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D04DC242B09; Wed, 17 Mar 2021 07:26:31 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 5D611242B06 for ; Wed, 17 Mar 2021 07:26:30 +0100 (CET) IronPort-SDR: GTzjccHszgHRHELdrOrpPR6v1WSaoCjhL1iIBx6+7DE/cgpcQMu8g3JJyVUp0KjrRqYlMSlmkm Idp1PxhmEKlA== X-IronPort-AV: E=McAfee;i="6000,8403,9925"; a="186041217" X-IronPort-AV: E=Sophos;i="5.81,255,1610438400"; d="scan'208";a="186041217" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2021 23:26:30 -0700 IronPort-SDR: qCFBzBpcwidOtHye2ewuHxjNsomY1jMOhgFXBo0fMkoJX7lkNk0KIsv1UCQFffRH37b6iV20ja L3CnpI37Fe/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,255,1610438400"; d="scan'208";a="433282926" Received: from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.118.193]) by fmsmga004.fm.intel.com with ESMTP; 16 Mar 2021 23:26:28 -0700 From: Jiayu Hu To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, yinan.wang@intel.com, cheng1.jiang@intel.com, sunil.pai.g@intel.com, Jiayu Hu Date: Wed, 17 Mar 2021 08:56:12 -0400 Message-Id: <1615985773-406787-4-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1615985773-406787-1-git-send-email-jiayu.hu@intel.com> References: <1615985773-406787-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH 3/4] vhost: avoid deadlock on async register 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" Users register async copy device when vhost queue is enabled. However, if VHOST_USER_F_PROTOCOL_FEATURES is not supported, a deadlock occurs inside rte_vhost_async_channel_register(), as vhost_user_msg_handler() already takes vq->access_lock before processing VHOST_USER_SET_VRING_KICK message. This patch removes calling vring_state_changed() in vhost_user_set_vring_kick() to avoid deadlock on async register. Signed-off-by: Jiayu Hu --- 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 399675c..a319c1c 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1919,9 +1919,6 @@ vhost_user_set_vring_kick(struct virtio_net **pdev, struct VhostUserMsg *msg, */ if (!(dev->features & (1ULL << VHOST_USER_F_PROTOCOL_FEATURES))) { vq->enabled = 1; - if (dev->notify_ops->vring_state_changed) - dev->notify_ops->vring_state_changed( - dev->vid, file.index, 1); } if (vq->ready) { From patchwork Wed Mar 17 12:56:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Jiayu" X-Patchwork-Id: 89328 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 412E4A00C2; Wed, 17 Mar 2021 07:26:54 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 80B53242B15; Wed, 17 Mar 2021 07:26:34 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 43945242B0D for ; Wed, 17 Mar 2021 07:26:32 +0100 (CET) IronPort-SDR: BnmVzIQLlPSykS9G0Jgadk23u4F4m54Vk3CZ/lp+I9qWmuvdrQaCVf2alFCb0KsyAydBrdwtLF eiGblIbVcW7A== X-IronPort-AV: E=McAfee;i="6000,8403,9925"; a="186041220" X-IronPort-AV: E=Sophos;i="5.81,255,1610438400"; d="scan'208";a="186041220" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Mar 2021 23:26:31 -0700 IronPort-SDR: CifljjufdVE212hhEsIKQ0h2tjLKdcff5BRRLGakQ0yRc2jhc51mMVx3YU3LBUHl2BcPzCHKaB 4XY4ofZeNLfQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,255,1610438400"; d="scan'208";a="433282934" Received: from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.118.193]) by fmsmga004.fm.intel.com with ESMTP; 16 Mar 2021 23:26:30 -0700 From: Jiayu Hu To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, yinan.wang@intel.com, cheng1.jiang@intel.com, sunil.pai.g@intel.com, Jiayu Hu Date: Wed, 17 Mar 2021 08:56:13 -0400 Message-Id: <1615985773-406787-5-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1615985773-406787-1-git-send-email-jiayu.hu@intel.com> References: <1615985773-406787-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH 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" Signed-off-by: Jiayu Hu --- doc/guides/prog_guide/vhost_lib.rst | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst index dc29229..333bd0a 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,13 @@ 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. + + To guarantee correct behaviors, users must unregister async + copy devices for all vhost queues, when virtio device is paused + or shut down. Note that this API tries to acquire the spinlock + of vhost queue, so users need stop polling thread before unregister. * ``rte_vhost_submit_enqueue_burst(vid, queue_id, pkts, count, comp_pkts, comp_count)``