DPDK patches and discussions
 help / color / mirror / Atom feed
From: Frank Du <frank.du@intel.com>
To: dev@dpdk.org
Subject: [PATCH] net/af_xdp: parse numa node id from sysfs
Date: Mon, 12 Dec 2022 08:48:57 +0800	[thread overview]
Message-ID: <20221212004857.2004805-1-frank.du@intel.com> (raw)

Get from /sys/class/net/{if}/device/numa_node.

Signed-off-by: Frank Du <frank.du@intel.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index b6ec9bf490..38b9d36ab5 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -39,6 +39,7 @@
 #include <rte_power_intrinsics.h>
 
 #include "compat.h"
+#include "eal_filesystem.h"
 
 #ifndef SO_PREFER_BUSY_POLL
 #define SO_PREFER_BUSY_POLL 69
@@ -2038,9 +2039,6 @@ rte_pmd_af_xdp_probe(struct rte_vdev_device *dev)
 		return -EINVAL;
 	}
 
-	if (dev->device.numa_node == SOCKET_ID_ANY)
-		dev->device.numa_node = rte_socket_id();
-
 	if (parse_parameters(kvlist, if_name, &xsk_start_queue_idx,
 			     &xsk_queue_cnt, &shared_umem, prog_path,
 			     &busy_budget, &force_copy) < 0) {
@@ -2053,6 +2051,19 @@ rte_pmd_af_xdp_probe(struct rte_vdev_device *dev)
 		return -EINVAL;
 	}
 
+	/* get numa node id from net sysfs */
+	if (dev->device.numa_node == SOCKET_ID_ANY) {
+		unsigned long numa = 0;
+		char numa_path[PATH_MAX];
+
+		snprintf(numa_path, sizeof(numa_path), "/sys/class/net/%s/device/numa_node",
+			 if_name);
+		if (eal_parse_sysfs_value(numa_path, &numa) != 0)
+			dev->device.numa_node = rte_socket_id();
+		else
+			dev->device.numa_node = numa;
+	}
+
 	busy_budget = busy_budget == -1 ? ETH_AF_XDP_DFLT_BUSY_BUDGET :
 					busy_budget;
 
-- 
2.34.1


             reply	other threads:[~2022-12-12  1:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12  0:48 Frank Du [this message]
2023-01-16 13:15 ` Ferruh Yigit
2023-01-17  1:35   ` Du, Frank
2023-01-17  9:13     ` Ferruh Yigit
2023-01-18  1:53       ` Du, Frank
2023-01-18 10:19         ` Ferruh Yigit
2023-01-18 11:07 ` Ferruh Yigit

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=20221212004857.2004805-1-frank.du@intel.com \
    --to=frank.du@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;
as well as URLs for NNTP newsgroup(s).