[PATCH v2] malloc: enhance NUMA affinity heuristic

David Marchand david.marchand at redhat.com
Tue Jan 3 11:58:25 CET 2023


Trying to allocate memory on the first detected numa node has less
chance to find some memory actually available rather than on the main
lcore numa node (especially when the DPDK application is started only
on one numa node).

Signed-off-by: David Marchand <david.marchand at redhat.com>
---
Changes since v1:
- accomodate for configurations with main lcore running on multiples
  physical cores belonging to different numa,

---
 lib/eal/common/malloc_heap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c
index d7c410b786..fcb3fbebb9 100644
--- a/lib/eal/common/malloc_heap.c
+++ b/lib/eal/common/malloc_heap.c
@@ -717,6 +717,10 @@ malloc_get_numa_socket(void)
 			return socket_id;
 	}
 
+	socket_id = rte_lcore_to_socket(rte_get_main_lcore());
+	if (socket_id != (unsigned int)SOCKET_ID_ANY)
+		return socket_id;
+
 	return rte_socket_id_by_idx(0);
 }
 
-- 
2.38.1



More information about the dev mailing list