From: Anatoly Burakov Date: Thu, 25 Oct 2018 11:06:34 +0000 (+0100) Subject: malloc: fix external heap allocation in no-huge mode X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=5640171c528aa6462b556f180764f4d8539d711e;p=dpdk.git malloc: fix external heap allocation in no-huge mode When no-huge mode is enabled, we always overwrite the socket ID to be SOCKET_ID_ANY in rte_malloc, because there is no NUMA awareness in no-huge mode. However, with external memory support, a socket ID may have other meaning, and we cannot overwrite the socket ID in those cases. Fixes: 65ff37b105f7 ("malloc: add function to check if socket is external") Signed-off-by: Anatoly Burakov --- diff --git a/lib/librte_eal/common/rte_malloc.c b/lib/librte_eal/common/rte_malloc.c index b27a8ad2e2..9e61dc41bf 100644 --- a/lib/librte_eal/common/rte_malloc.c +++ b/lib/librte_eal/common/rte_malloc.c @@ -46,7 +46,13 @@ rte_malloc_socket(const char *type, size_t size, unsigned int align, if (size == 0 || (align && !rte_is_power_of_2(align))) return NULL; - if (!rte_eal_has_hugepages()) + /* if there are no hugepages and if we are not allocating from an + * external heap, use memory from any socket available. checking for + * socket being external may return -1 in case of invalid socket, but + * that's OK - if there are no hugepages, it doesn't matter. + */ + if (rte_malloc_heap_socket_is_external(socket_arg) != 1 && + !rte_eal_has_hugepages()) socket_arg = SOCKET_ID_ANY; return malloc_heap_alloc(type, size, socket_arg, 0,