DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jonathan Erb <jonathan.erb@threatblockr.com>
To: Thomas Monjalon <thomas@monjalon.net>,
	Anatoly Burakov <anatoly.burakov@intel.com>
Cc: dev@dpdk.org, Jonathan Erb <jonathan.erb@threatblockr.com>,
	stable@dpdk.org
Subject: [PATCH] eal/linux: prevent deadlocks on rte init and cleanup
Date: Mon, 17 Jul 2023 21:00:46 -0400	[thread overview]
Message-ID: <20230718010047.456679-1-jonathan.erb@threatblockr.com> (raw)

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(-)

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;
 }
-- 
2.34.1


             reply	other threads:[~2023-07-20  5:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18  1:00 Jonathan Erb [this message]
2023-09-29 14:32 ` David Marchand
2023-10-02 14:34   ` Jonathan Erb

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=20230718010047.456679-1-jonathan.erb@threatblockr.com \
    --to=jonathan.erb@threatblockr.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    --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).