From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 479EE2965 for ; Fri, 29 Mar 2019 10:53:06 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2019 02:53:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,284,1549958400"; d="scan'208";a="138422614" Received: from ultraviolet.igk.intel.com ([10.102.17.137]) by fmsmga007.fm.intel.com with ESMTP; 29 Mar 2019 02:53:03 -0700 From: Darek Stojaczyk To: dev@dpdk.org Cc: james.r.harris@intel.com, changpeng.liu@intel.com, gavin.hu@arm.com, Darek Stojaczyk , anatoly.burakov@intel.com, thomas@monjalon.net Date: Fri, 29 Mar 2019 10:52:39 +0100 Message-Id: <20190329095239.9646-1-dariusz.stojaczyk@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190329050951.153202-1-dariusz.stojaczyk@intel.com> References: <20190329050951.153202-1-dariusz.stojaczyk@intel.com> Subject: [dpdk-dev] [PATCH v2] fbarray: fix attach deadlock 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: , X-List-Received-Date: Fri, 29 Mar 2019 09:53:06 -0000 rte_fbarray_attach() currently locks its internal spinlock, but never releases it. Secondary processes won't even start if there is more than one fbarray to be attached to - the second rte_fbarray_attach() would be just stuck. Fix it by releasing the lock at the end of rte_fbarray_attach(). I believe this was the original intention. Fixes: 5b61c62cfd76 ("fbarray: add internal tailq for mapped areas") Cc: anatoly.burakov@intel.com Cc: thomas@monjalon.net Signed-off-by: Darek Stojaczyk Reviewed-by: Gavin Hu --- v2: - fixed one more case where we could unlock the spinlock before locking it lib/librte_eal/common/eal_common_fbarray.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/eal_common_fbarray.c b/lib/librte_eal/common/eal_common_fbarray.c index 0e7366e5e..31cce80a8 100644 --- a/lib/librte_eal/common/eal_common_fbarray.c +++ b/lib/librte_eal/common/eal_common_fbarray.c @@ -859,8 +859,10 @@ rte_fbarray_attach(struct rte_fbarray *arr) } page_sz = sysconf(_SC_PAGESIZE); - if (page_sz == (size_t)-1) - goto fail; + if (page_sz == (size_t)-1) { + free(ma); + return -1; + } mmap_len = calc_data_size(page_sz, arr->elt_sz, arr->len); @@ -906,6 +908,7 @@ rte_fbarray_attach(struct rte_fbarray *arr) /* we're done */ + rte_spinlock_unlock(&mem_area_lock); return 0; fail: if (data) @@ -913,6 +916,7 @@ rte_fbarray_attach(struct rte_fbarray *arr) if (fd >= 0) close(fd); free(ma); + rte_spinlock_unlock(&mem_area_lock); return -1; } -- 2.17.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 9B63AA05D3 for ; Fri, 29 Mar 2019 10:53:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 667E82BD3; Fri, 29 Mar 2019 10:53:07 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 479EE2965 for ; Fri, 29 Mar 2019 10:53:06 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Mar 2019 02:53:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,284,1549958400"; d="scan'208";a="138422614" Received: from ultraviolet.igk.intel.com ([10.102.17.137]) by fmsmga007.fm.intel.com with ESMTP; 29 Mar 2019 02:53:03 -0700 From: Darek Stojaczyk To: dev@dpdk.org Cc: james.r.harris@intel.com, changpeng.liu@intel.com, gavin.hu@arm.com, Darek Stojaczyk , anatoly.burakov@intel.com, thomas@monjalon.net Date: Fri, 29 Mar 2019 10:52:39 +0100 Message-Id: <20190329095239.9646-1-dariusz.stojaczyk@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190329050951.153202-1-dariusz.stojaczyk@intel.com> References: <20190329050951.153202-1-dariusz.stojaczyk@intel.com> Subject: [dpdk-dev] [PATCH v2] fbarray: fix attach deadlock 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190329095239.weM_vVDpBiJIS-1KkAxNFzJYZ0DCQUMye8OTBld4QBA@z> rte_fbarray_attach() currently locks its internal spinlock, but never releases it. Secondary processes won't even start if there is more than one fbarray to be attached to - the second rte_fbarray_attach() would be just stuck. Fix it by releasing the lock at the end of rte_fbarray_attach(). I believe this was the original intention. Fixes: 5b61c62cfd76 ("fbarray: add internal tailq for mapped areas") Cc: anatoly.burakov@intel.com Cc: thomas@monjalon.net Signed-off-by: Darek Stojaczyk Reviewed-by: Gavin Hu --- v2: - fixed one more case where we could unlock the spinlock before locking it lib/librte_eal/common/eal_common_fbarray.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/eal_common_fbarray.c b/lib/librte_eal/common/eal_common_fbarray.c index 0e7366e5e..31cce80a8 100644 --- a/lib/librte_eal/common/eal_common_fbarray.c +++ b/lib/librte_eal/common/eal_common_fbarray.c @@ -859,8 +859,10 @@ rte_fbarray_attach(struct rte_fbarray *arr) } page_sz = sysconf(_SC_PAGESIZE); - if (page_sz == (size_t)-1) - goto fail; + if (page_sz == (size_t)-1) { + free(ma); + return -1; + } mmap_len = calc_data_size(page_sz, arr->elt_sz, arr->len); @@ -906,6 +908,7 @@ rte_fbarray_attach(struct rte_fbarray *arr) /* we're done */ + rte_spinlock_unlock(&mem_area_lock); return 0; fail: if (data) @@ -913,6 +916,7 @@ rte_fbarray_attach(struct rte_fbarray *arr) if (fd >= 0) close(fd); free(ma); + rte_spinlock_unlock(&mem_area_lock); return -1; } -- 2.17.1