eal/linux: prevent deadlocks on rte init and cleanup

Message ID 20230718010047.456679-1-jonathan.erb@threatblockr.com (mailing list archive)
State Not Applicable, archived
Delegated to: David Marchand
Headers
Series eal/linux: prevent deadlocks on rte init and cleanup |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-unit-testing fail Testing issues
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Jonathan Erb July 18, 2023, 1 a.m. UTC
  Resolves a deadlock that can occur when multiple secondary
processes are starting and stopping. A deadlock can occur because
eal_memalloc_init() is taking a second unnecessary read lock.
If another DPDK process that is terminating enters rte_eal_memory_detach()
and acquires a write lock wait state before the starting process can
acquire it's second read lock then no process will be able to proceed.

Cc: stable@dpdk.org

Signed-off-by: Jonathan Erb <jonathan.erb@threatblockr.com>
---
 .mailmap                     | 2 +-
 lib/eal/linux/eal_memalloc.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
  

Comments

David Marchand Sept. 29, 2023, 2:32 p.m. UTC | #1
Hello Jonathan,

On Thu, Jul 20, 2023 at 7:19 AM Jonathan Erb
<jonathan.erb@threatblockr.com> wrote:
>
> Resolves a deadlock that can occur when multiple secondary
> processes are starting and stopping. A deadlock can occur because
> eal_memalloc_init() is taking a second unnecessary read lock.
> If another DPDK process that is terminating enters rte_eal_memory_detach()
> and acquires a write lock wait state before the starting process can
> acquire it's second read lock then no process will be able to proceed.
>
> Cc: stable@dpdk.org
>
> Signed-off-by: Jonathan Erb <jonathan.erb@threatblockr.com>

Thanks for the report and fix and sorry for the late reply.

Artemy came with a similar report and a more complete fix.
Could you confirm it works for you?

https://patchwork.dpdk.org/project/dpdk/list/?series=29463&state=%2A&archive=both


Thanks,
  
Jonathan Erb Oct. 2, 2023, 2:34 p.m. UTC | #2
David,

Thanks for the follow-up. The proposed patch below from Artemy will work 
for me.

Jonathan


On 9/29/23 10:32, David Marchand wrote:
> Hello Jonathan,
>
> On Thu, Jul 20, 2023 at 7:19 AM Jonathan Erb
> <jonathan.erb@threatblockr.com>  wrote:
>> Resolves a deadlock that can occur when multiple secondary
>> processes are starting and stopping. A deadlock can occur because
>> eal_memalloc_init() is taking a second unnecessary read lock.
>> If another DPDK process that is terminating enters rte_eal_memory_detach()
>> and acquires a write lock wait state before the starting process can
>> acquire it's second read lock then no process will be able to proceed.
>>
>> Cc:stable@dpdk.org
>>
>> Signed-off-by: Jonathan Erb<jonathan.erb@threatblockr.com>
> Thanks for the report and fix and sorry for the late reply.
>
> Artemy came with a similar report and a more complete fix.
> Could you confirm it works for you?
>
> https://patchwork.dpdk.org/project/dpdk/list/?series=29463&state=%2A&archive=both
>
>
> Thanks,
>
  

Patch

diff --git a/.mailmap b/.mailmap
index 6eccf0c555..a64bfcf1d2 100644
--- a/.mailmap
+++ b/.mailmap
@@ -663,7 +663,7 @@  John OLoughlin <john.oloughlin@intel.com>
 John Ousterhout <ouster@cs.stanford.edu>
 John W. Linville <linville@tuxdriver.com>
 Jonas Pfefferle <jpf@zurich.ibm.com> <pepperjo@japf.ch>
-Jonathan Erb <jonathan.erb@banduracyber.com>
+Jonathan Erb <jonathan.erb@threatblockr.com>
 Jon DeVree <nuxi@vault24.org>
 Jon Loeliger <jdl@netgate.com>
 Joongi Kim <joongi@an.kaist.ac.kr>
diff --git a/lib/eal/linux/eal_memalloc.c b/lib/eal/linux/eal_memalloc.c
index f8b1588cae..a34f1cf2f9 100644
--- a/lib/eal/linux/eal_memalloc.c
+++ b/lib/eal/linux/eal_memalloc.c
@@ -1740,7 +1740,7 @@  eal_memalloc_init(void)
 		eal_get_internal_configuration();
 
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
-		if (rte_memseg_list_walk(secondary_msl_create_walk, NULL) < 0)
+		if (rte_memseg_list_walk_thread_unsafe(secondary_msl_create_walk, NULL) < 0)
 			return -1;
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY &&
 			internal_conf->in_memory) {
@@ -1778,7 +1778,7 @@  eal_memalloc_init(void)
 	}
 
 	/* initialize all of the fd lists */
-	if (rte_memseg_list_walk(fd_list_create_walk, NULL))
+	if (rte_memseg_list_walk_thread_unsafe(fd_list_create_walk, NULL))
 		return -1;
 	return 0;
 }