[dpdk-dev] [PATCH v1 18/28] eal/soc: detect numa_node of the rte_soc_device
Jan Viktorin
viktorin at rehivetech.com
Fri May 6 15:48:00 CEST 2016
No idea whether this is useful. Who creates the numa_node in the sysfs?
This can be probably dropped later.
Signed-off-by: Jan Viktorin <viktorin at rehivetech.com>
---
lib/librte_eal/common/eal_common_soc.c | 8 ++++----
lib/librte_eal/common/include/rte_soc.h | 1 +
lib/librte_eal/linuxapp/eal/eal_soc.c | 26 ++++++++++++++++++++++++++
3 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_soc.c b/lib/librte_eal/common/eal_common_soc.c
index d0e5351..af4daa5 100644
--- a/lib/librte_eal/common/eal_common_soc.c
+++ b/lib/librte_eal/common/eal_common_soc.c
@@ -108,8 +108,8 @@ rte_eal_soc_probe_one_driver(struct rte_soc_driver *dr,
if (!soc_id_match(dr->id_table, dev->id))
return 1;
- RTE_LOG(DEBUG, EAL, "SoC device %s\n",
- dev->addr.name);
+ RTE_LOG(DEBUG, EAL, "SoC device %s on NUMA socket %d\n",
+ dev->addr.name, dev->numa_node);
RTE_LOG(DEBUG, EAL, " probe driver %s\n", dr->name);
if (dev->devargs != NULL
@@ -162,8 +162,8 @@ rte_eal_soc_detach_dev(struct rte_soc_driver *dr,
if (!soc_id_match(dr->id_table, dev->id))
return 1;
- RTE_LOG(DEBUG, EAL, "SoC device %s\n",
- dev->addr.name);
+ RTE_LOG(DEBUG, EAL, "SoC device %s on NUMA socket %i\n",
+ dev->addr.name, dev->numa_node);
RTE_LOG(DEBUG, EAL, " remove driver: %s\n", dr->name);
diff --git a/lib/librte_eal/common/include/rte_soc.h b/lib/librte_eal/common/include/rte_soc.h
index 830fcdc..49cfeb7 100644
--- a/lib/librte_eal/common/include/rte_soc.h
+++ b/lib/librte_eal/common/include/rte_soc.h
@@ -99,6 +99,7 @@ struct rte_soc_device {
struct rte_soc_resource mem_resource[SOC_MAX_RESOURCE];
struct rte_intr_handle intr_handle; /**< Interrupt handle */
struct rte_soc_driver *driver; /**< Associated driver */
+ int numa_node; /**< NUMA node connection */
struct rte_devargs *devargs; /**< Device user arguments */
enum rte_kernel_driver kdrv; /**< Kernel driver */
};
diff --git a/lib/librte_eal/linuxapp/eal/eal_soc.c b/lib/librte_eal/linuxapp/eal/eal_soc.c
index c0e123a..6ef7d2f 100644
--- a/lib/librte_eal/linuxapp/eal/eal_soc.c
+++ b/lib/librte_eal/linuxapp/eal/eal_soc.c
@@ -45,6 +45,7 @@
#include <rte_soc.h>
#include "eal_internal_cfg.h"
+#include "eal_filesystem.h"
#include "eal_private.h"
int
@@ -294,6 +295,28 @@ dev_setup_associated_driver(struct rte_soc_device *dev, const char *dirname)
return 0;
}
+static int
+dev_setup_numa_node(struct rte_soc_device *dev, const char *dirname)
+{
+ char filename[PATH_MAX];
+ FILE *f;
+ /* if no NUMA support, set default to 0 */
+ unsigned long tmp = 0;
+ int ret = 0;
+
+ /* get numa node */
+ snprintf(filename, sizeof(filename), "%s/numa_node", dirname);
+ if ((f = fopen(filename, "r")) != NULL) {
+ if (eal_parse_sysfs_valuef(f, &tmp) < 0)
+ ret = 1;
+
+ fclose(f);
+ }
+
+ dev->numa_node = tmp;
+ return ret;
+}
+
/**
* Scan one SoC sysfs entry, and fill the devices list from it.
* We require to have the uevent file with records: OF_FULLNAME and
@@ -335,6 +358,9 @@ soc_scan_one(const char *dirname, const char *name)
if ((ret = dev_setup_associated_driver(dev, dirname)))
goto fail;
+ if ((ret = dev_setup_numa_node(dev, dirname)) < 0)
+ goto fail;
+
/* device is valid, add in list (sorted) */
if (TAILQ_EMPTY(&soc_device_list)) {
TAILQ_INSERT_TAIL(&soc_device_list, dev, next);
--
2.8.0
More information about the dev
mailing list