From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Aman Singh <aman.deep.singh@intel.com>
Subject: [PATCH 2/4] app/testpmd: consolidate port socket ID computation
Date: Thu, 2 Jul 2026 09:10:12 -0700 [thread overview]
Message-ID: <20260702161244.363233-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20260702161244.363233-1-stephen@networkplumber.org>
The socket id of a port was computed in three places with
diverging copies of the same policy:
- init_config() and init_fwd_streams() duplicated the full policy
(--port-numa-config, device socket id, first available socket,
--socket-num);
- setup_attached_port() used only the device socket id and ignored
--port-numa-config, --no-numa and --socket-num, so a hot-attached
port could be keyed to a socket where no mbuf pool exists.
Move the policy into a single helper, port_socket_id(), and use it
in all three places.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
app/test-pmd/testpmd.c | 69 +++++++++++++++++-------------------------
1 file changed, 28 insertions(+), 41 deletions(-)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index b5dca03047..04f0e15bee 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1740,6 +1740,31 @@ uma_socket_id(void)
(unsigned int)SOCKET_ID_ANY : socket_num;
}
+/*
+ * Socket id to use for a port: the socket its mbuf pools are created
+ * on and where its queue resources are placed.
+ */
+static unsigned int
+port_socket_id(portid_t pid)
+{
+ unsigned int socket_id;
+
+ if (!numa_support)
+ return uma_socket_id();
+
+ socket_id = port_numa[pid];
+ if (socket_id == NUMA_NO_CONFIG) {
+ socket_id = rte_eth_dev_socket_id(pid);
+ /*
+ * If socket_id is invalid,
+ * set to the first available socket.
+ */
+ if (check_socket_id(socket_id) < 0)
+ socket_id = socket_ids[0];
+ }
+ return socket_id;
+}
+
static void
init_config(void)
{
@@ -1774,25 +1799,8 @@ init_config(void)
}
RTE_ETH_FOREACH_DEV(pid) {
- uint32_t socket_id;
-
- if (numa_support) {
- socket_id = port_numa[pid];
- if (port_numa[pid] == NUMA_NO_CONFIG) {
- socket_id = rte_eth_dev_socket_id(pid);
-
- /*
- * if socket_id is invalid,
- * set to the first available socket.
- */
- if (check_socket_id(socket_id) < 0)
- socket_id = socket_ids[0];
- }
- } else {
- socket_id = uma_socket_id();
- }
/* Apply default TxRx configuration for all ports */
- init_config_port_offloads(pid, socket_id);
+ init_config_port_offloads(pid, port_socket_id(pid));
}
/*
* Create pools of mbuf.
@@ -1916,23 +1924,7 @@ init_fwd_streams(void)
nb_txq, port->dev_info.max_tx_queues);
return -1;
}
- if (numa_support) {
- if (port_numa[pid] != NUMA_NO_CONFIG)
- port->socket_id = port_numa[pid];
- else {
- port->socket_id = rte_eth_dev_socket_id(pid);
-
- /*
- * if socket_id is invalid,
- * set to the first available socket.
- */
- if (check_socket_id(port->socket_id) < 0)
- port->socket_id = socket_ids[0];
- }
- }
- else {
- port->socket_id = uma_socket_id();
- }
+ port->socket_id = port_socket_id(pid);
}
q = RTE_MAX(nb_rxq, nb_txq);
@@ -3604,14 +3596,9 @@ attach_port(char *identifier)
static void
setup_attached_port(portid_t pi)
{
- unsigned int socket_id;
int ret;
- socket_id = (unsigned)rte_eth_dev_socket_id(pi);
- /* if socket_id is invalid, set to the first available socket. */
- if (check_socket_id(socket_id) < 0)
- socket_id = socket_ids[0];
- reconfig(pi, socket_id);
+ reconfig(pi, port_socket_id(pi));
ret = rte_eth_promiscuous_enable(pi);
if (ret != 0)
fprintf(stderr,
--
2.53.0
next prev parent reply other threads:[~2026-07-02 16:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 13:07 [PATCH] app/testpmd: fix multi-pool Rx setup with --no-NUMA Maayan Kashani
2026-07-02 16:10 ` [PATCH 0/4] app/testpmd: fix socket id handling with NUMA disabled Stephen Hemminger
2026-07-02 16:10 ` [PATCH 1/4] app/testpmd: fix port socket ID " Stephen Hemminger
2026-07-02 16:10 ` Stephen Hemminger [this message]
2026-07-02 16:10 ` [PATCH 3/4] app/testpmd: display any socket ID as text Stephen Hemminger
2026-07-02 16:10 ` [PATCH 4/4] app/testpmd: report reason when queue setup command fails Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260702161244.363233-3-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=aman.deep.singh@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox