From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, james.r.harris@intel.com
Subject: [dpdk-dev] [PATCH] mem: fix deadlock on secondary allocation
Date: Fri, 29 Jan 2021 15:29:51 +0000 [thread overview]
Message-ID: <4e0688f841f6ba2408fde949aabce8e36c0d46f0.1611934186.git.anatoly.burakov@intel.com> (raw)
Previous fix used `rte_malloc_heap_socket_is_external()` to check if the
heap was an external heap. However, that API is thread-safe, and when
we're inside the allocation process, we're already write-locked, so
calling `rte_malloc_heap_socket_is_external()` will result in a
deadlock followed by a timeout.
Fix it by replacing the API call with a check against maximum number of
NUMA nodes, because external heaps always have higher socket ID's.
Fixes: 7ac31e82bc8f ("mem: improve parameter checking on memory hotplug")
Reported-by: Jim Harris <james.r.harris@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
lib/librte_eal/common/malloc_mp.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/librte_eal/common/malloc_mp.c b/lib/librte_eal/common/malloc_mp.c
index 0b19d4d5fb..b1f7f7824b 100644
--- a/lib/librte_eal/common/malloc_mp.c
+++ b/lib/librte_eal/common/malloc_mp.c
@@ -241,8 +241,13 @@ handle_alloc_request(const struct malloc_mp_req *m,
heap = &mcfg->malloc_heaps[ar->malloc_heap_idx];
- /* for allocations, we must only use internal heaps */
- if (rte_malloc_heap_socket_is_external(heap->socket_id)) {
+ /*
+ * for allocations, we must only use internal heaps, but since the
+ * rte_malloc_heap_socket_is_external() is thread-safe and we're already
+ * read-locked, we'll have to take advantage of the fac that internal
+ * socket ID's are always lower than RTE_MAX_NUMA_NODES.
+ */
+ if (heap->socket_id >= RTE_MAX_NUMA_NODES) {
RTE_LOG(ERR, EAL, "Attempting to allocate from external heap\n");
return -1;
}
--
2.25.1
next reply other threads:[~2021-01-29 15:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-29 15:29 Anatoly Burakov [this message]
2021-01-29 15:40 ` Thomas Monjalon
2021-01-29 16:07 ` Burakov, Anatoly
2021-01-29 23:37 ` 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=4e0688f841f6ba2408fde949aabce8e36c0d46f0.1611934186.git.anatoly.burakov@intel.com \
--to=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--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).