[PATCH v3] malloc: enhance NUMA affinity heuristic

You, KaisenX kaisenx.you at intel.com
Tue Jan 31 04:23:46 CET 2023



> -----Original Message-----
> From: David Marchand <david.marchand at redhat.com>
> Sent: 2023年1月3日 21:32
> To: dev at dpdk.org
> Cc: Matz, Olivier <olivier.matz at 6wind.com>; ferruh.yigit at amd.com; You,
> KaisenX <kaisenx.you at intel.com>; zhoumin at loongson.cn; Burakov, Anatoly
> <anatoly.burakov at intel.com>
> Subject: [PATCH v3] malloc: enhance NUMA affinity heuristic
> 
> 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 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/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..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);
>  }
> 
Because the initial "socket_id" of the interrupt thread is not necessarily 
"SOCKET_ID_ANY"(-1), in malloc_get_numa_socket(void) function, It may 
be returned before the content modified by this patch, resulting in the 
subsequent search for memory being performed on the socket that initializes 
the unallocated memory. 

To avoid this, I will submit the V4 version to fix this problem.

> --
> 2.39.0



More information about the dev mailing list