Skip to content

Commit

Permalink
enhance NUMA affinity heuristic
Browse files Browse the repository at this point in the history
When a DPDK application is started on only one numa node, memory is
allocated for only one socket. When interrupt threads use memory,
memory may not be found on the socket where the interrupt thread
is currently located, and memory has to be reallocated on the hugepage,
this operation will lead to performance degradation.

Fixes: 705356f ("eal: simplify control thread creation")
Fixes: 770d41b ("malloc: fix allocation with unknown socket ID")
Cc: stable@dpdk.org

Signed-off-by: Kaisen You <kaisenx.you@intel.com>
Signed-off-by: 0-day Robot <robot@bytheb.org>
  • Loading branch information
youkaisen authored and ovsrobot committed May 23, 2023
1 parent a399d7b commit 21ac165
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/eal/common/eal_common_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ static int ctrl_thread_init(void *arg)
struct rte_thread_ctrl_params *params = arg;

__rte_thread_init(rte_lcore_id(), cpuset);
/* set the value of the per-core variable _socket_id to SOCKET_ID_ANY.
* Satisfy the judgment condition when threads find memory.
* If SOCKET_ID_ANY is not specified, the thread may go to a node with
* unallocated memory in a subsequent memory search.
*/
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,
Expand Down
9 changes: 9 additions & 0 deletions lib/eal/common/malloc_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,15 @@ malloc_get_numa_socket(void)
if (conf->socket_mem[socket_id] != 0)
return socket_id;
}
/* Trying to allocate memory on the main lcore numa node.
* especially when the DPDK application is started only on one numa node.
*/
socket_id = rte_lcore_to_socket_id(rte_get_main_lcore());
/* When the socket_id obtained in the main lcore numa is SOCKET_ID_ANY,
* The probability of finding memory on rte_socket_id_by_idx(0) is higher.
*/
if (socket_id != (unsigned int)SOCKET_ID_ANY)
return socket_id;

return rte_socket_id_by_idx(0);
}
Expand Down

0 comments on commit 21ac165

Please sign in to comment.