[PATCH 186/227] examples/distributor: use NUMA node terminology

Chengwen Feng chengwen.feng at linux.dev
Tue Nov 3 15:52:24 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>
---
 examples/distributor/main.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 344da03814..a81e09b6ef 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -156,7 +156,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 
 	for (q = 0; q < rxRings; q++) {
 		retval = rte_eth_rx_queue_setup(port, q, nb_rxd,
-						rte_eth_dev_socket_id(port),
+						rte_eth_dev_numa_id(port),
 						NULL, mbuf_pool);
 		if (retval < 0)
 			return retval;
@@ -166,7 +166,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 	txconf.offloads = port_conf.txmode.offloads;
 	for (q = 0; q < txRings; q++) {
 		retval = rte_eth_tx_queue_setup(port, q, nb_txd,
-						rte_eth_dev_socket_id(port),
+						rte_eth_dev_numa_id(port),
 						&txconf);
 		if (retval < 0)
 			return retval;
@@ -226,7 +226,7 @@ static int
 lcore_rx(struct lcore_params *p)
 {
 	const uint16_t nb_ports = rte_eth_dev_count_avail();
-	const int socket_id = rte_socket_id();
+	const int numa_id = rte_numa_id();
 	uint16_t port;
 	struct rte_mbuf *bufs[BURST_SIZE*2];
 
@@ -235,8 +235,8 @@ lcore_rx(struct lcore_params *p)
 		if ((enabled_port_mask & (1 << port)) == 0)
 			continue;
 
-		if (rte_eth_dev_socket_id(port) >= 0 &&
-				rte_eth_dev_socket_id(port) != socket_id)
+		if (rte_eth_dev_numa_id(port) >= 0 &&
+				rte_eth_dev_numa_id(port) != numa_id)
 			printf("WARNING, port %u is on remote NUMA node to "
 					"RX thread.\n\tPerformance will not "
 					"be optimal.\n", port);
@@ -295,7 +295,7 @@ lcore_rx_and_distributor(struct lcore_params *p)
 {
 	struct rte_distributor *d = p->d;
 	const uint16_t nb_ports = rte_eth_dev_count_avail();
-	const int socket_id = rte_socket_id();
+	const int numa_id = rte_numa_id();
 	uint16_t port;
 	struct rte_mbuf *bufs[BURST_SIZE*2];
 
@@ -304,8 +304,8 @@ lcore_rx_and_distributor(struct lcore_params *p)
 		if ((enabled_port_mask & (1 << port)) == 0)
 			continue;
 
-		if (rte_eth_dev_socket_id(port) > 0 &&
-				rte_eth_dev_socket_id(port) != socket_id)
+		if (rte_eth_dev_numa_id(port) > 0 &&
+				rte_eth_dev_numa_id(port) != numa_id)
 			printf("WARNING, port %u is on remote NUMA node to "
 					"RX thread.\n\tPerformance will not "
 					"be optimal.\n", port);
@@ -465,7 +465,7 @@ static int
 lcore_tx(struct rte_ring *in_r)
 {
 	static struct output_buffer tx_buffers[RTE_MAX_ETHPORTS];
-	const int socket_id = rte_socket_id();
+	const int numa_id = rte_numa_id();
 	uint16_t port;
 
 	RTE_ETH_FOREACH_DEV(port) {
@@ -473,8 +473,8 @@ lcore_tx(struct rte_ring *in_r)
 		if ((enabled_port_mask & (1 << port)) == 0)
 			continue;
 
-		if (rte_eth_dev_socket_id(port) >= 0 &&
-				rte_eth_dev_socket_id(port) != socket_id)
+		if (rte_eth_dev_numa_id(port) >= 0 &&
+				rte_eth_dev_numa_id(port) != numa_id)
 			printf("WARNING, port %u is on remote NUMA node to "
 					"TX thread.\n\tPerformance will not "
 					"be optimal.\n", port);
@@ -828,7 +828,7 @@ main(int argc, char *argv[])
 
 	mbuf_pool = rte_pktmbuf_pool_create("MBUF_POOL",
 		NUM_MBUFS * nb_ports, MBUF_CACHE_SIZE, 0,
-		RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id());
+		RTE_MBUF_DEFAULT_BUF_SIZE, rte_numa_id());
 	if (mbuf_pool == NULL)
 		rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");
 	nb_ports_available = nb_ports;
@@ -854,7 +854,7 @@ main(int argc, char *argv[])
 				"All available ports are disabled. Please set portmask.\n");
 	}
 
-	d = rte_distributor_create("PKT_DIST", rte_socket_id(),
+	d = rte_distributor_create("PKT_DIST", rte_numa_id(),
 			num_workers,
 			RTE_DIST_ALG_BURST);
 	if (d == NULL)
@@ -865,12 +865,12 @@ main(int argc, char *argv[])
 	 * by scheduler core
 	 */
 	dist_tx_ring = rte_ring_create("Output_ring", SCHED_TX_RING_SZ,
-			rte_socket_id(), RING_F_SC_DEQ | RING_F_SP_ENQ);
+			rte_numa_id(), RING_F_SC_DEQ | RING_F_SP_ENQ);
 	if (dist_tx_ring == NULL)
 		rte_exit(EXIT_FAILURE, "Cannot create output ring\n");
 
 	rx_dist_ring = rte_ring_create("Input_ring", SCHED_RX_RING_SZ,
-			rte_socket_id(), RING_F_SC_DEQ | RING_F_SP_ENQ);
+			rte_numa_id(), RING_F_SC_DEQ | RING_F_SP_ENQ);
 	if (rx_dist_ring == NULL)
 		rte_exit(EXIT_FAILURE, "Cannot create output ring\n");
 
-- 
2.55.0



More information about the dev mailing list