[PATCH 207/227] examples/multi_process: use NUMA node terminology
Chengwen Feng
chengwen.feng at linux.dev
Tue Nov 3 15:52:45 CET 2026
From: Chengwen Feng <fengchengwen at huawei.com>
Rename socket_id parameters, local variables and comments to the
NUMA node terminology, and switch calls to the NUMA-named APIs.
Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
---
.../client_server_mp/mp_client/client.c | 4 ++--
.../client_server_mp/mp_server/init.c | 14 +++++++-------
examples/multi_process/simple_mp/main.c | 6 +++---
examples/multi_process/symmetric_mp/main.c | 6 +++---
4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/examples/multi_process/client_server_mp/mp_client/client.c b/examples/multi_process/client_server_mp/mp_client/client.c
index 087c38ef73..8f6f5bfd5e 100644
--- a/examples/multi_process/client_server_mp/mp_client/client.c
+++ b/examples/multi_process/client_server_mp/mp_client/client.c
@@ -135,9 +135,9 @@ configure_tx_buffer(uint16_t port_id, uint16_t size)
int ret;
/* Initialize TX buffers */
- tx_buffer[port_id] = rte_zmalloc_socket("tx_buffer",
+ tx_buffer[port_id] = rte_zmalloc_numa("tx_buffer",
RTE_ETH_TX_BUFFER_SIZE(size), 0,
- rte_eth_dev_socket_id(port_id));
+ rte_eth_dev_numa_id(port_id));
if (tx_buffer[port_id] == NULL)
rte_exit(EXIT_FAILURE, "Cannot allocate buffer for tx on port %u\n",
port_id);
diff --git a/examples/multi_process/client_server_mp/mp_server/init.c b/examples/multi_process/client_server_mp/mp_server/init.c
index 09cb363ab8..ed00540bdb 100644
--- a/examples/multi_process/client_server_mp/mp_server/init.c
+++ b/examples/multi_process/client_server_mp/mp_server/init.c
@@ -75,7 +75,7 @@ init_mbuf_pools(void)
printf("Creating mbuf pool '%s' [%u mbufs] ...\n",
PKTMBUF_POOL_NAME, num_mbufs);
pktmbuf_pool = rte_pktmbuf_pool_create(PKTMBUF_POOL_NAME, num_mbufs,
- MBUF_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());
+ MBUF_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_numa_id());
return pktmbuf_pool == NULL; /* 0 on success */
}
@@ -127,14 +127,14 @@ init_port(uint16_t port_num)
for (q = 0; q < rx_rings; q++) {
retval = rte_eth_rx_queue_setup(port_num, q, rx_ring_size,
- rte_eth_dev_socket_id(port_num),
+ rte_eth_dev_numa_id(port_num),
NULL, pktmbuf_pool);
if (retval < 0) return retval;
}
for ( q = 0; q < tx_rings; q ++ ) {
retval = rte_eth_tx_queue_setup(port_num, q, tx_ring_size,
- rte_eth_dev_socket_id(port_num),
+ rte_eth_dev_numa_id(port_num),
NULL);
if (retval < 0) return retval;
}
@@ -160,7 +160,7 @@ static int
init_shm_rings(void)
{
unsigned i;
- unsigned socket_id;
+unsigned int numa_id
const char * q_name;
const unsigned ringsize = CLIENT_QUEUE_RINGSIZE;
@@ -171,10 +171,10 @@ init_shm_rings(void)
for (i = 0; i < num_clients; i++) {
/* Create an RX queue for each client */
- socket_id = rte_socket_id();
+ numa_id = rte_numa_id();
q_name = get_rx_queue_name(i);
clients[i].rx_q = rte_ring_create(q_name,
- ringsize, socket_id,
+ ringsize, numa_id,
RING_F_SP_ENQ | RING_F_SC_DEQ ); /* single prod, single cons */
if (clients[i].rx_q == NULL)
rte_exit(EXIT_FAILURE, "Cannot create rx ring queue for client %u\n", i);
@@ -263,7 +263,7 @@ init(int argc, char *argv[])
/* set up array for port data */
mz = rte_memzone_reserve(MZ_PORT_INFO, sizeof(*ports),
- rte_socket_id(), NO_FLAGS);
+ rte_numa_id(), NO_FLAGS);
if (mz == NULL)
rte_exit(EXIT_FAILURE, "Cannot reserve memory zone for port information\n");
memset(mz->addr, 0, sizeof(*ports));
diff --git a/examples/multi_process/simple_mp/main.c b/examples/multi_process/simple_mp/main.c
index d73d1358ff..7378e1677e 100644
--- a/examples/multi_process/simple_mp/main.c
+++ b/examples/multi_process/simple_mp/main.c
@@ -89,12 +89,12 @@ main(int argc, char **argv)
/* Start of ring structure. 8< */
if (rte_eal_process_type() == RTE_PROC_PRIMARY){
- send_ring = rte_ring_create(_PRI_2_SEC, ring_size, rte_socket_id(), flags);
- recv_ring = rte_ring_create(_SEC_2_PRI, ring_size, rte_socket_id(), flags);
+ send_ring = rte_ring_create(_PRI_2_SEC, ring_size, rte_numa_id(), flags);
+ recv_ring = rte_ring_create(_SEC_2_PRI, ring_size, rte_numa_id(), flags);
message_pool = rte_mempool_create(_MSG_POOL, pool_size,
STR_TOKEN_SIZE, pool_cache, priv_data_sz,
NULL, NULL, NULL, NULL,
- rte_socket_id(), flags);
+ rte_numa_id(), flags);
} else {
recv_ring = rte_ring_lookup(_PRI_2_SEC);
send_ring = rte_ring_lookup(_SEC_2_PRI);
diff --git a/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c
index 19347b403c..0207a92aae 100644
--- a/examples/multi_process/symmetric_mp/main.c
+++ b/examples/multi_process/symmetric_mp/main.c
@@ -263,7 +263,7 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
rxq_conf.offloads = port_conf.rxmode.offloads;
for (q = 0; q < rx_rings; q ++) {
retval = rte_eth_rx_queue_setup(port, q, nb_rxd,
- rte_eth_dev_socket_id(port),
+ rte_eth_dev_numa_id(port),
&rxq_conf,
mbuf_pool);
if (retval < 0)
@@ -274,7 +274,7 @@ smp_port_init(uint16_t port, struct rte_mempool *mbuf_pool,
txq_conf.offloads = port_conf.txmode.offloads;
for (q = 0; q < tx_rings; q ++) {
retval = rte_eth_tx_queue_setup(port, q, nb_txd,
- rte_eth_dev_socket_id(port),
+ rte_eth_dev_numa_id(port),
&txq_conf);
if (retval < 0)
return retval;
@@ -470,7 +470,7 @@ main(int argc, char **argv)
rte_mempool_lookup(_SMP_MBUF_POOL) :
rte_pktmbuf_pool_create(_SMP_MBUF_POOL, NB_MBUFS,
MBUF_CACHE_SIZE, 0, RTE_MBUF_DEFAULT_BUF_SIZE,
- rte_socket_id());
+ rte_numa_id());
if (mp == NULL)
rte_exit(EXIT_FAILURE, "Cannot get memory pool for buffers\n");
--
2.55.0
More information about the dev
mailing list