mem: fix deadlock on secondary allocation
authorAnatoly Burakov <anatoly.burakov@intel.com>
Fri, 29 Jan 2021 15:29:51 +0000 (15:29 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 29 Jan 2021 23:26:49 +0000 (00:26 +0100)
commit7e54f18326ca157b5187183bc77838d122cb2564
treec6aaa1e03c059b4a34594c4091ea2849890a47d0
parent293ca0aaafaaed4b0ff96f5fec30fbd54f8e9cb3
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 <james.r.harris@intel.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
lib/librte_eal/common/malloc_mp.c