From patchwork Fri Apr 2 13:03:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Jiayu" X-Patchwork-Id: 90450 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 BB192A0548; Fri, 2 Apr 2021 08:34:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1D8D140F95; Fri, 2 Apr 2021 08:34:16 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 9B72F40150; Fri, 2 Apr 2021 08:34:14 +0200 (CEST) IronPort-SDR: kvJcZJdTFgL1fpJBcocT0kw9x0LKaN053ZNcPFsHoxHIybtC8xhZxVww1BJYNS6/ubAEQ/tsqL Ip70zpWyT0rg== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="189144948" X-IronPort-AV: E=Sophos;i="5.81,299,1610438400"; d="scan'208";a="189144948" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 23:34:14 -0700 IronPort-SDR: 9tXHG73qcTA8OjIaiYdK2K0Pu89d3PoB5bTz8LoO0ribA4rD5n10VFesP89z6f67oGgKtYHDxd 4c+E/GUfb+RA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,299,1610438400"; d="scan'208";a="413042740" Received: from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.118.193]) by fmsmga008.fm.intel.com with ESMTP; 01 Apr 2021 23:34:11 -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 , stable@dpdk.org Date: Fri, 2 Apr 2021 09:03:59 -0400 Message-Id: <1617368642-131298-2-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617368642-131298-1-git-send-email-jiayu.hu@intel.com> References: <1615985773-406787-1-git-send-email-jiayu.hu@intel.com> <1617368642-131298-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH v2 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 --- 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 c9d1371..8657bbe 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -609,7 +609,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 Fri Apr 2 13:04:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Jiayu" X-Patchwork-Id: 90451 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 E7B0CA0548; Fri, 2 Apr 2021 08:34:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 44115140FAA; Fri, 2 Apr 2021 08:34:18 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 6C0CA140F94 for ; Fri, 2 Apr 2021 08:34:16 +0200 (CEST) IronPort-SDR: GPLAaNCp356u/gSVAq6JBDr3jzkKZPsD319lS2Y/gQdAti6IRIPD2eV0YNA4WFSOZM1k/2r0w1 I0VHNvdQAUxg== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="189144950" X-IronPort-AV: E=Sophos;i="5.81,299,1610438400"; d="scan'208";a="189144950" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 23:34:16 -0700 IronPort-SDR: pTs8QVA4vtyN2gBa9CY6ld+qwO5/p3/VjcAMDUt90AOIvtueDVaNqa8tBQ5UAKVPtiDvBilHCT 2lpPWCSVa28g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,299,1610438400"; d="scan'208";a="413042760" Received: from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.118.193]) by fmsmga008.fm.intel.com with ESMTP; 01 Apr 2021 23:34:14 -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 Date: Fri, 2 Apr 2021 09:04:00 -0400 Message-Id: <1617368642-131298-3-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617368642-131298-1-git-send-email-jiayu.hu@intel.com> References: <1615985773-406787-1-git-send-email-jiayu.hu@intel.com> <1617368642-131298-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH v2 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 2f4f89a..44c0452 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -2009,13 +2009,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 Fri Apr 2 13:04:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Jiayu" X-Patchwork-Id: 90452 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 1F465A0548; Fri, 2 Apr 2021 08:34:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3A27140FE3; Fri, 2 Apr 2021 08:34:19 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 75016140FBB for ; Fri, 2 Apr 2021 08:34:18 +0200 (CEST) IronPort-SDR: E7+NrIa5THk+7MJBYCnCYm6n3Qn/Ra3L6zXNLYYzgqthdBIxgJG0t3SQg/W2efwWntR1WvEVVI q4/sKMQeqp5A== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="189144954" X-IronPort-AV: E=Sophos;i="5.81,299,1610438400"; d="scan'208";a="189144954" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 23:34:18 -0700 IronPort-SDR: wBP9nTLHdgLdrQWCZB2jIRLaBSh3gOnQIugj0xf+YFzvFqkksUke3Bc1y/z1dmyRtApz5i1Ll0 n3W+1O6V7C4A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,299,1610438400"; d="scan'208";a="413042784" Received: from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.118.193]) by fmsmga008.fm.intel.com with ESMTP; 01 Apr 2021 23:34:16 -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 Date: Fri, 2 Apr 2021 09:04:01 -0400 Message-Id: <1617368642-131298-4-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617368642-131298-1-git-send-email-jiayu.hu@intel.com> References: <1615985773-406787-1-git-send-email-jiayu.hu@intel.com> <1617368642-131298-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH v2 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 can register async copy device in vring_state_changed(), when vhost queue is enabled. However, a deadlock occurs inside rte_vhost_async_channel_register(), if VHOST_USER_F_PROTOCOL_FEATURES is not supported, as vhost_user_msg_handler() takes vq->access_lock before calling vhost_user_set_vring_kick(). This patch avoids async register deadlock by removing calling vring_state_changed() in vhost_user_set_vring_kick(). It's safe as vhost_user_msg_handler() will call vring_state_changed() anyway. 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 44c0452..8f0eba6 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -1918,9 +1918,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 Fri Apr 2 13:04:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Jiayu" X-Patchwork-Id: 90453 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 A21A5A0548; Fri, 2 Apr 2021 08:34:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 04B34140FF0; Fri, 2 Apr 2021 08:34:22 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 51490140FE9 for ; Fri, 2 Apr 2021 08:34:20 +0200 (CEST) IronPort-SDR: PHHja45fWsRyGzmvjhpyYeIsv/nBqoSG4K3xnjefMcmm3LAIxWXasc+1DWouHRQ9qyHWhSNpPJ 2q+HyzkTEGGw== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="189144958" X-IronPort-AV: E=Sophos;i="5.81,299,1610438400"; d="scan'208";a="189144958" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 23:34:20 -0700 IronPort-SDR: 3Hcxl1gJBickABlWEJa2PllIdnX8gbUdtAUTlsNts27jL929yprx8fkDFZeEF9xLEA/v/RRnGg odqA3aENqjQQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,299,1610438400"; d="scan'208";a="413042813" Received: from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.118.193]) by fmsmga008.fm.intel.com with ESMTP; 01 Apr 2021 23:34:18 -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 Date: Fri, 2 Apr 2021 09:04:02 -0400 Message-Id: <1617368642-131298-5-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617368642-131298-1-git-send-email-jiayu.hu@intel.com> References: <1615985773-406787-1-git-send-email-jiayu.hu@intel.com> <1617368642-131298-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH v2 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)``