fbarray: fix attach deadlock
PATCH 1/1 fbarray: fix attach deadlock
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.
--- lib/librte_eal/common/eal_common_fbarray.c | 2 ++ 1 file changed, 2 insertions(+)
lib/librte_eal/common/eal_common_fbarray.c +2 -0
@@ -906,6 +906,7 @@ rte_fbarray_attach(struct rte_fbarray *arr)/* we're done */ +rte_spinlock_unlock (&mem_area_lock);return 0 ; fail:if (data)
@@ -913,6 +914,7 @@ rte_fbarray_attach(struct rte_fbarray *arr)if (fd >=0 )close (fd);free (ma); +rte_spinlock_unlock (&mem_area_lock);return -1 ; }
Signature · 1 line
2.17.1
Quoted 44 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Darek Stojaczyk
Sent: Friday, March 29, 2019 1:10 PM
To: [email protected]
Cc: [email protected]; [email protected]; Darek Stojaczyk <[email protected]>; [email protected]; [email protected]
Subject: [dpdk-dev] [PATCH] fbarray: fix attach deadlock
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 secondrte_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")Signed-off-by Darek Stojaczyk <[email protected]>--- lib/librte_eal/common/eal_common_fbarray.c | 2 ++ 1 file changed, 2 insertions(+)lib/librte_eal/common/eal_common_fbarray.c +1
-0@@ -906,6 +906,7 @@ rte_fbarray_attach(struct rte_fbarray *arr)/* we're done */ +rte_spinlock_unlock (&mem_area_lock);return 0 ; fail:if (data)
lib/librte_eal/common/eal_common_fbarray.c rte_fbarray_attach(struct rte_fbarray *arr) · line 919
Quoted 6 lines
lib/librte_eal/common/eal_common_fbarray.c +1
-0@@ -913,6 +914,7 @@ rte_fbarray_attach(struct rte_fbarray *arr)if (fd >=0 )close (fd);free (ma); +rte_spinlock_unlock (&mem_area_lock);return -1 ; }
This is an obvious issue, good catch!
Quoted 2 lines
lib/librte_eal/common/eal_common_fbarray.c +0
-1--2.17.1
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
PATCH v2 1/1 fbarray: fix attach deadlock
In reply to Darek Stojaczykrte_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.
---
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(-)
lib/librte_eal/common/eal_common_fbarray.c +6 -2
@@ -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 ; }
Signature · 1 line
2.17.1
Quoted 14 lines · Darek Stojaczyk
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 secondrte_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")
Quoted 6 lines
Signed-off-by Darek Stojaczyk <[email protected]>Reviewed-by Gavin Hu <[email protected]>---
v2:
- fixed one more case where we could unlock the spinlock before locking it
Thanks for catching this!
There is one more case where we do unlock on init without locking, i'll submit a patch separately (and will check other functions with a microscope just in case).
Signature · 2 lines
Thanks, Anatoly
Thomas Monjalon
Applied29/03/2019 11:42, Burakov, Anatoly:
Quoted 22 lines · Darek Stojaczyk
Quoted 14 lines
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 secondrte_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")Quoted 6 lines
Signed-off-by Darek Stojaczyk <[email protected]>Reviewed-by Gavin Hu <[email protected]>---
v2:
- fixed one more case where we could unlock the spinlock before locking it
Quoted 3 lines
Thanks for catching this!
Acked-by Anatoly Burakov <[email protected]>
Applied, thanks
Quoted 3 lines
There is one more case where we do unlock on init without locking, i'll submit a patch separately (and will check other functions with a microscope just in case).
We'll take this one too.