[v4] net/iavf:enhance NUMA affinity heuristic

Message ID 20230131150501.1180476-1-kaisenx.you@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v4] net/iavf:enhance NUMA affinity heuristic |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Kaisen You Jan. 31, 2023, 3:05 p.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).

Fixes: 705356f0811f ("eal: simplify control thread creation")
Fixes: bb0bd346d5c1 ("eal: suggest using --lcores option")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Kaisen You <kaisenx.you@intel.com>
---
Changes since v3:
- add the assignment of socket_id in thread initialization,

Changes since v2:
- add uncommitted local change and fix compilation,

Changes since v1:
- accomodate for configurations with main lcore running on multiples
  physical cores belonging to different numa,
---
 lib/eal/common/eal_common_thread.c | 1 +
 lib/eal/common/malloc_heap.c       | 4 ++++
 2 files changed, 5 insertions(+)
  

Comments

Thomas Monjalon Jan. 31, 2023, 4:05 p.m. UTC | #1
31/01/2023 16:05, Kaisen You:
>  lib/eal/common/eal_common_thread.c | 1 +
>  lib/eal/common/malloc_heap.c       | 4 ++++
>  2 files changed, 5 insertions(+)

Why the title refers to net/iavf?
  
Kaisen You Feb. 1, 2023, 5:32 a.m. UTC | #2
> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: 2023年2月1日 0:06
> To: You, KaisenX <kaisenx.you@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org; Zhou, YidingX
> <yidingx.zhou@intel.com>; david.marchand@redhat.com; Matz, Olivier
> <olivier.matz@6wind.com>; ferruh.yigit@amd.com; You, KaisenX
> <kaisenx.you@intel.com>; zhoumin@loongson.cn; Burakov, Anatoly
> <anatoly.burakov@intel.com>; stable@dpdk.org
> Subject: Re: [PATCH v4] net/iavf:enhance NUMA affinity heuristic
> 
> 31/01/2023 16:05, Kaisen You:
> >  lib/eal/common/eal_common_thread.c | 1 +
> >  lib/eal/common/malloc_heap.c       | 4 ++++
> >  2 files changed, 5 insertions(+)
> 
> Why the title refers to net/iavf?

Sorry, the issue that was solved before is related to net/iavf. 
The new solution is compatible with all situations. I will release a new patch.
>
  

Patch

diff --git a/lib/eal/common/eal_common_thread.c b/lib/eal/common/eal_common_thread.c
index 38d83a6885..21bff971f8 100644
--- a/lib/eal/common/eal_common_thread.c
+++ b/lib/eal/common/eal_common_thread.c
@@ -251,6 +251,7 @@  static void *ctrl_thread_init(void *arg)
 	void *routine_arg = params->arg;
 
 	__rte_thread_init(rte_lcore_id(), cpuset);
+	RTE_PER_LCORE(_socket_id) = SOCKET_ID_ANY;
 	params->ret = rte_thread_set_affinity_by_id(rte_thread_self(), cpuset);
 	if (params->ret != 0) {
 		__atomic_store_n(&params->ctrl_thread_status,
diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c
index d7c410b786..3ee19aee15 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_id(rte_get_main_lcore());
+	if (socket_id != (unsigned int)SOCKET_ID_ANY)
+		return socket_id;
+
 	return rte_socket_id_by_idx(0);
 }