From: Anatoly Burakov Date: Fri, 29 Jan 2021 15:29:51 +0000 (+0000) Subject: mem: fix deadlock on secondary allocation X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7e54f18326ca157b5187183bc77838d122cb2564;p=dpdk.git mem: fix deadlock on secondary allocation 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 Signed-off-by: Anatoly Burakov --- diff --git a/lib/librte_eal/common/malloc_mp.c b/lib/librte_eal/common/malloc_mp.c index 0b19d4d5fb..c7101b32d3 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 fact 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; }