[v2] malloc: enhance NUMA affinity heuristic

Message ID 20230103105825.616810-1-david.marchand@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series [v2] malloc: enhance NUMA affinity heuristic |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation fail ninja build failure
ci/iol-testing fail build patch failure
ci/github-robot: build fail github build: failed
ci/Intel-compilation fail Compilation issues

Commit Message

David Marchand Jan. 3, 2023, 10:58 a.m. UTC
  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@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(+)
  

Patch

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);
 }