From: Cunming Liang Date: Tue, 17 Feb 2015 02:08:09 +0000 (+0800) Subject: malloc: avoid unknown socket id X-Git-Tag: spdx-start~9572 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b94580d6887eab82629cc6b4319a664ddd0de2fb;p=dpdk.git malloc: avoid unknown socket id Add check for rte_socket_id(), avoid get unexpected return like (-1). By using rte_malloc_socket(), socket id is assigned by socket_arg. If socket_arg set to SOCKET_ID_ANY, it expects to use the socket id to which the current cores belongs. As the thread may affinity on a cpuset, the cores in the cpuset may belongs to different NUMA nodes. The value of _socket_id probably be SOCKET_ID_ANY(-1), the case is not expected in origin malloc_get_numa_socket(). Signed-off-by: Cunming Liang Acked-by: Olivier Matz Acked-by: Konstantin Ananyev --- diff --git a/lib/librte_malloc/malloc_heap.h b/lib/librte_malloc/malloc_heap.h index b4aec45119..a47136d851 100644 --- a/lib/librte_malloc/malloc_heap.h +++ b/lib/librte_malloc/malloc_heap.h @@ -44,7 +44,12 @@ extern "C" { static inline unsigned malloc_get_numa_socket(void) { - return rte_socket_id(); + unsigned socket_id = rte_socket_id(); + + if (socket_id == (unsigned)SOCKET_ID_ANY) + return 0; + + return socket_id; } void *