From: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
To: dev@dpdk.org
Cc: james.r.harris@intel.com, changpeng.liu@intel.com,
gavin.hu@arm.com, Darek Stojaczyk <dariusz.stojaczyk@intel.com>,
anatoly.burakov@intel.com, thomas@monjalon.net
Subject: [dpdk-dev] [PATCH v2] fbarray: fix attach deadlock
Date: Fri, 29 Mar 2019 10:52:39 +0100 [thread overview]
Message-ID: <20190329095239.9646-1-dariusz.stojaczyk@intel.com> (raw)
Message-ID: <20190329095239.weM_vVDpBiJIS-1KkAxNFzJYZ0DCQUMye8OTBld4QBA@z> (raw)
In-Reply-To: <20190329050951.153202-1-dariusz.stojaczyk@intel.com>
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 <dariusz.stojaczyk@intel.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>
---
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
next prev parent reply other threads:[~2019-03-29 9:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-29 5:09 [dpdk-dev] [PATCH] " Darek Stojaczyk
2019-03-29 5:09 ` Darek Stojaczyk
2019-03-29 8:53 ` Gavin Hu (Arm Technology China)
2019-03-29 8:53 ` Gavin Hu (Arm Technology China)
2019-03-29 9:52 ` Darek Stojaczyk [this message]
2019-03-29 9:52 ` [dpdk-dev] [PATCH v2] " Darek Stojaczyk
2019-03-29 10:42 ` Burakov, Anatoly
2019-03-29 10:42 ` Burakov, Anatoly
2019-03-29 11:15 ` Thomas Monjalon
2019-03-29 11:15 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190329095239.9646-1-dariusz.stojaczyk@intel.com \
--to=dariusz.stojaczyk@intel.com \
--cc=anatoly.burakov@intel.com \
--cc=changpeng.liu@intel.com \
--cc=dev@dpdk.org \
--cc=gavin.hu@arm.com \
--cc=james.r.harris@intel.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).