drivers/bus: set device NUMA node to unknown by default
Subsystems (2)
PATCH 1/1 drivers/bus: set device NUMA node to unknown by default
The dev->device.numa_node field is set by each bus driver for every device it manages to indicate on which NUMA node this device lies.
When this information is unknown, the assigned value is not consistent across the bus drivers.
Set the default value to SOCKET_ID_ANY (-1) by all bus drivers when the NUMA information is unavailable.
--- doc/guides/rel_notes/deprecation.rst | 7 ------- doc/guides/rel_notes/release_22_11.rst | 6 ++++++ drivers/bus/auxiliary/auxiliary_common.c | 8 ++------ drivers/bus/auxiliary/linux/auxiliary.c | 13 +++++-------- drivers/bus/dpaa/dpaa_bus.c | 1 + drivers/bus/fslmc/fslmc_bus.c | 1 + drivers/bus/pci/bsd/pci.c | 2 +- drivers/bus/pci/linux/pci.c | 16 ++++++---------- drivers/bus/pci/pci_common.c | 8 ++------ drivers/bus/pci/windows/pci.c | 1 - drivers/bus/vmbus/linux/vmbus_bus.c | 1 - drivers/bus/vmbus/vmbus_common.c | 8 ++------ 12 files changed, 26 insertions(+), 46 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -7
@@ -36,13 +36,6 @@ Deprecation Notices ``__atomic_thread_fence`` must be used for patches that need to be merged in 20.08 onwards. This change will not introduce any performance degradation. -* bus: The ``dev->device.numa_node`` field is set by each bus driver for - every device it manages to indicate on which NUMA node this device lies. - When this information is unknown, the assigned value is not consistent - across the bus drivers. - In DPDK 22.11, the default value will be set to -1 by all bus drivers - when the NUMA information is unavailable. - * kni: The KNI kernel module and library are not recommended for use by new applications - other technologies such as virtio-user are recommended instead. Following the DPDK technical board
doc/guides/rel_notes/release_22_11.rst +6 -0
@@ -266,6 +266,12 @@ ABI Changes * eventdev: Added ``weight`` and ``affinity`` fields to ``rte_event_queue_conf`` structure. +* bus: Changed the device numa node to -1 when NUMA information is unavailable. + The ``dev->device.numa_node`` field is set by each bus driver for + every device it manages to indicate on which NUMA node this device lies. + When this information is unknown, the assigned value was not consistent + across the bus drivers. + Known Issues ------------
drivers/bus/auxiliary/auxiliary_common.c +2 -6
@@ -105,12 +105,8 @@ rte_auxiliary_probe_one_driver(struct rte_auxiliary_driver *drv,return -1 ; } -if (dev->device.numa_node <0 ) { -if (rte_socket_count () >1 ) -AUXILIARY_LOG (INFO ,"Device %s is not NUMA-aware, defaulting socket to 0" , - dev->name); - dev->device.numa_node =0 ; - } +if (dev->device.numa_node <0 &&rte_socket_count () >1 ) +RTE_LOG (INFO ,EAL ,"Device %s is not NUMA-aware\n" , dev->name); iova_mode =rte_eal_iova_mode (); if ((drv->drv_flags & RTE_AUXILIARY_DRV_NEED_IOVA_AS_VA) > 0 &&
drivers/bus/auxiliary/linux/auxiliary.c +5 -8
@@ -40,14 +40,11 @@ auxiliary_scan_one(const char *dirname, const char *name)/* Get NUMA node, default to 0 if not present */ snprintf (filename,sizeof (filename),"%s/%s/numa_node" , dirname, name); -if (access (filename,F_OK ) !=-1 ) { -if (eal_parse_sysfs_value (filename, &tmp) ==0 ) - dev->device.numa_node = tmp; -else - dev->device.numa_node =-1 ; - }else { - dev->device.numa_node =0 ; - } +if (access (filename,F_OK ) ==0 && +eal_parse_sysfs_value (filename, &tmp) ==0 ) + dev->device.numa_node = tmp; +else + dev->device.numa_node =SOCKET_ID_ANY ;auxiliary_on_scan (dev);
drivers/bus/dpaa/dpaa_bus.c +1 -0
@@ -179,6 +179,7 @@ dpaa_create_device_list(void) } dev->device.bus = &rte_dpaa_bus.bus; + dev->device.numa_node =SOCKET_ID_ANY ;/* Allocate interrupt handle instance */ dev->intr_handle =
drivers/bus/fslmc/fslmc_bus.c +1 -0
@@ -156,6 +156,7 @@ scan_one_fslmc_device(char *dev_name) } dev->device.bus = &rte_fslmc_bus.bus; + dev->device.numa_node =SOCKET_ID_ANY ;/* Allocate interrupt instance */ dev->intr_handle =
drivers/bus/pci/bsd/pci.c +1 -1
@@ -246,7 +246,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) dev->max_vfs =0 ;/* FreeBSD has no NUMA support (yet) */ - dev->device.numa_node =0 ; + dev->device.numa_node =SOCKET_ID_ANY ;pci_common_set (dev);
drivers/bus/pci/linux/pci.c +6 -10
@@ -283,17 +283,13 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr) }/* get numa node, default to 0 if not present */ -snprintf (filename,sizeof (filename),"%s/numa_node" , - dirname); +snprintf (filename,sizeof (filename),"%s/numa_node" , dirname); -if (access (filename,F_OK ) !=-1 ) { -if (eal_parse_sysfs_value (filename, &tmp) ==0 ) - dev->device.numa_node = tmp; -else - dev->device.numa_node =-1 ; - }else { - dev->device.numa_node =0 ; - } +if (access (filename,F_OK ) ==0 && +eal_parse_sysfs_value (filename, &tmp) ==0 ) + dev->device.numa_node = tmp; +else + dev->device.numa_node =SOCKET_ID_ANY ;pci_common_set (dev);
drivers/bus/pci/pci_common.c +2 -6
@@ -235,12 +235,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,return 1 ; } -if (dev->device.numa_node <0 ) { -if (rte_socket_count () >1 ) -RTE_LOG (INFO ,EAL ,"Device %s is not NUMA-aware, defaulting socket to 0\n" , - dev->name); - dev->device.numa_node =0 ; - } +if (dev->device.numa_node <0 &&rte_socket_count () >1 ) +RTE_LOG (INFO ,EAL ,"Device %s is not NUMA-aware\n" , dev->name); already_probed =rte_dev_is_probed (&dev->device);if (already_probed && !(dr->drv_flags &RTE_PCI_DRV_PROBE_AGAIN )) {
drivers/bus/pci/windows/pci.c +0 -1
@@ -249,7 +249,6 @@ get_device_resource_info(HDEVINFO dev_info,DWORD error =GetLastError ();if (error ==ERROR_NOT_FOUND ) {/* On older CPUs, NUMA is not bound to PCIe locality. */ - dev->device.numa_node =0 ;return ERROR_SUCCESS ; } RTE_LOG_WIN32_ERR("SetupDiGetDevicePropertyW"
drivers/bus/vmbus/linux/vmbus_bus.c +0 -1
@@ -293,7 +293,6 @@ vmbus_scan_one(const char *name) goto error; dev->device.numa_node = tmp; }else { -/* if no NUMA support, set default to 0 */ dev->device.numa_node =SOCKET_ID_ANY ; }
drivers/bus/vmbus/vmbus_common.c +2 -6
@@ -111,12 +111,8 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,/* reference driver structure */ dev->driver = dr; -if (dev->device.numa_node <0 ) { -if (rte_socket_count () >1 ) -VMBUS_LOG (INFO ,"Device %s is not NUMA-aware, defaulting socket to 0" , - guid); - dev->device.numa_node =0 ; - } +if (dev->device.numa_node <0 &&rte_socket_count () >1 ) +VMBUS_LOG (INFO ,"Device %s is not NUMA-aware" , guid);/* call the driver probe() function */ VMBUS_LOG (INFO ," probe driver: %s" , dr->driver.name);
Signature · 1 line
2.30.2
Quoted 11 lines · Olivier Matz
The
dev->device.numa_nodefield is set by each bus driver for every device it manages to indicate on which NUMA node this device lies.When this information is unknown, the assigned value is not consistent across the bus drivers.
Set the default value to
SOCKET_ID_ANY(-1) by all bus drivers when the NUMA information is unavailable.Signed-off-by Olivier Matz <[email protected]>
- The dma/idxd driver, which has its own bus, seems ok, though I would align its code for readability.
@@ -322,7 +322,7 @@ dsa_scan(void)
while ((wq = readdir(dev_dir)) != NULL) {
struct rte_dsa_device *dev;- int numa_node = -1;
+ int numa_node = SOCKET_ID_ANY;
if (strncmp(wq->d_name, "wq", 2) != 0)
continue;- There is an impact on upper classes of devices.
For ethdev, a port inherits the numa_node value from the rte_device object. Yet, rte_eth_dev_socket_id() is described as:
* @return
* The NUMA socket ID to which the Ethernet device is connected or * a default of zero if the socket could not be determined. * -1 is returned is the port_id value is out of range.
Signature · 1 line
David marchand
Quoted 29 lines · David Marchand
Quoted 11 lines · Olivier Matz
The
dev->device.numa_nodefield is set by each bus driver for every device it manages to indicate on which NUMA node this device lies.When this information is unknown, the assigned value is not consistent across the bus drivers.
Set the default value to
SOCKET_ID_ANY(-1) by all bus drivers when the NUMA information is unavailable.Signed-off-by Olivier Matz <[email protected]>- The dma/idxd driver, which has its own bus, seems ok, though I would align its code for readability.
(quoted diff) +1
-2@@ -322,7 +322,7 @@ dsa_scan(void) while ((wq = readdir(dev_dir)) != NULL) { struct rte_dsa_device *dev; - int numa_node = -1; + int numa_node = SOCKET_ID_ANY; if (strncmp(wq->d_name, "wq", 2) != 0) continue; - There is an impact on upper classes of devices.
Quoted 6 lines
For ethdev, a port inherits the
numa_nodevalue from therte_deviceobject. Yet,rte_eth_dev_socket_id()is described as:
* @return* The NUMA socket ID to which the Ethernet device is connected or * a default of zero if the socket could not be determined. * -1 is returned is the port_id value is out of range.
Good catches, I'll fix them in v2.
Thanks,
Olivier
PATCH v2 1/1 drivers/bus: set device NUMA node to unknown by default
In reply to David MarchandThe dev->device.numa_node field is set by each bus driver for every device it manages to indicate on which NUMA node this device lies.
When this information is unknown, the assigned value is not consistent across the bus drivers.
Set the default value to SOCKET_ID_ANY (-1) by all bus drivers when the NUMA information is unavailable. This change impacts rte_eth_dev_socket_id() in the same manner.
---
v2
* use SOCKET_ID_ANY instead of -1 in drivers/dma/idxd (David)
* document the behavior change of rte_eth_dev_socket_id()
* fix few examples where rte_eth_dev_socket_id() was expected to return 0 on unknown socket
doc/guides/rel_notes/deprecation.rst | 7 ------- doc/guides/rel_notes/release_22_11.rst | 6 ++++++ drivers/bus/auxiliary/auxiliary_common.c | 8 ++------ drivers/bus/auxiliary/linux/auxiliary.c | 13 +++++-------- drivers/bus/dpaa/dpaa_bus.c | 1 + drivers/bus/fslmc/fslmc_bus.c | 1 + drivers/bus/pci/bsd/pci.c | 2 +- drivers/bus/pci/linux/pci.c | 16 ++++++---------- drivers/bus/pci/pci_common.c | 8 ++------ drivers/bus/pci/windows/pci.c | 1 - drivers/bus/vmbus/linux/vmbus_bus.c | 1 - drivers/bus/vmbus/vmbus_common.c | 8 ++------ drivers/dma/idxd/idxd_bus.c | 3 ++- examples/distributor/main.c | 4 ++-- examples/flow_classify/flow_classify.c | 2 ++ examples/rxtx_callbacks/main.c | 2 +- lib/ethdev/rte_ethdev.h | 4 ++-- 17 files changed, 35 insertions(+), 52 deletions(-)
doc/guides/rel_notes/deprecation.rst +0 -7
@@ -33,13 +33,6 @@ Deprecation Notices ``__atomic_thread_fence`` must be used for patches that need to be merged in 20.08 onwards. This change will not introduce any performance degradation. -* bus: The ``dev->device.numa_node`` field is set by each bus driver for - every device it manages to indicate on which NUMA node this device lies. - When this information is unknown, the assigned value is not consistent - across the bus drivers. - In DPDK 22.11, the default value will be set to -1 by all bus drivers - when the NUMA information is unavailable. - * kni: The KNI kernel module and library are not recommended for use by new applications - other technologies such as virtio-user are recommended instead. Following the DPDK technical board
doc/guides/rel_notes/release_22_11.rst +6 -0
@@ -317,6 +317,12 @@ ABI Changes * eventdev: Added ``weight`` and ``affinity`` fields to ``rte_event_queue_conf`` structure. +* bus: Changed the device numa node to -1 when NUMA information is unavailable. + The ``dev->device.numa_node`` field is set by each bus driver for + every device it manages to indicate on which NUMA node this device lies. + When this information is unknown, the assigned value was not consistent + across the bus drivers. This similarly impacts ``rte_eth_dev_socket_id()``. + Known Issues ------------
drivers/bus/auxiliary/auxiliary_common.c +2 -6
@@ -105,12 +105,8 @@ rte_auxiliary_probe_one_driver(struct rte_auxiliary_driver *drv,return -1 ; } -if (dev->device.numa_node <0 ) { -if (rte_socket_count () >1 ) -AUXILIARY_LOG (INFO ,"Device %s is not NUMA-aware, defaulting socket to 0" , - dev->name); - dev->device.numa_node =0 ; - } +if (dev->device.numa_node <0 &&rte_socket_count () >1 ) +RTE_LOG (INFO ,EAL ,"Device %s is not NUMA-aware\n" , dev->name); iova_mode =rte_eal_iova_mode (); if ((drv->drv_flags & RTE_AUXILIARY_DRV_NEED_IOVA_AS_VA) > 0 &&
drivers/bus/auxiliary/linux/auxiliary.c +5 -8
@@ -40,14 +40,11 @@ auxiliary_scan_one(const char *dirname, const char *name)/* Get NUMA node, default to 0 if not present */ snprintf (filename,sizeof (filename),"%s/%s/numa_node" , dirname, name); -if (access (filename,F_OK ) !=-1 ) { -if (eal_parse_sysfs_value (filename, &tmp) ==0 ) - dev->device.numa_node = tmp; -else - dev->device.numa_node =-1 ; - }else { - dev->device.numa_node =0 ; - } +if (access (filename,F_OK ) ==0 && +eal_parse_sysfs_value (filename, &tmp) ==0 ) + dev->device.numa_node = tmp; +else + dev->device.numa_node =SOCKET_ID_ANY ;auxiliary_on_scan (dev);
drivers/bus/dpaa/dpaa_bus.c +1 -0
@@ -179,6 +179,7 @@ dpaa_create_device_list(void) } dev->device.bus = &rte_dpaa_bus.bus; + dev->device.numa_node =SOCKET_ID_ANY ;/* Allocate interrupt handle instance */ dev->intr_handle =
drivers/bus/fslmc/fslmc_bus.c +1 -0
@@ -156,6 +156,7 @@ scan_one_fslmc_device(char *dev_name) } dev->device.bus = &rte_fslmc_bus.bus; + dev->device.numa_node =SOCKET_ID_ANY ;/* Allocate interrupt instance */ dev->intr_handle =
drivers/bus/pci/bsd/pci.c +1 -1
@@ -246,7 +246,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) dev->max_vfs =0 ;/* FreeBSD has no NUMA support (yet) */ - dev->device.numa_node =0 ; + dev->device.numa_node =SOCKET_ID_ANY ;pci_common_set (dev);
drivers/bus/pci/linux/pci.c +6 -10
@@ -283,17 +283,13 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr) }/* get numa node, default to 0 if not present */ -snprintf (filename,sizeof (filename),"%s/numa_node" , - dirname); +snprintf (filename,sizeof (filename),"%s/numa_node" , dirname); -if (access (filename,F_OK ) !=-1 ) { -if (eal_parse_sysfs_value (filename, &tmp) ==0 ) - dev->device.numa_node = tmp; -else - dev->device.numa_node =-1 ; - }else { - dev->device.numa_node =0 ; - } +if (access (filename,F_OK ) ==0 && +eal_parse_sysfs_value (filename, &tmp) ==0 ) + dev->device.numa_node = tmp; +else + dev->device.numa_node =SOCKET_ID_ANY ;pci_common_set (dev);
drivers/bus/pci/pci_common.c +2 -6
@@ -235,12 +235,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr,return 1 ; } -if (dev->device.numa_node <0 ) { -if (rte_socket_count () >1 ) -RTE_LOG (INFO ,EAL ,"Device %s is not NUMA-aware, defaulting socket to 0\n" , - dev->name); - dev->device.numa_node =0 ; - } +if (dev->device.numa_node <0 &&rte_socket_count () >1 ) +RTE_LOG (INFO ,EAL ,"Device %s is not NUMA-aware\n" , dev->name); already_probed =rte_dev_is_probed (&dev->device);if (already_probed && !(dr->drv_flags &RTE_PCI_DRV_PROBE_AGAIN )) {
drivers/bus/pci/windows/pci.c +0 -1
@@ -249,7 +249,6 @@ get_device_resource_info(HDEVINFO dev_info,DWORD error =GetLastError ();if (error ==ERROR_NOT_FOUND ) {/* On older CPUs, NUMA is not bound to PCIe locality. */ - dev->device.numa_node =0 ;return ERROR_SUCCESS ; } RTE_LOG_WIN32_ERR("SetupDiGetDevicePropertyW"
drivers/bus/vmbus/linux/vmbus_bus.c +0 -1
@@ -293,7 +293,6 @@ vmbus_scan_one(const char *name) goto error; dev->device.numa_node = tmp; }else { -/* if no NUMA support, set default to 0 */ dev->device.numa_node =SOCKET_ID_ANY ; }
drivers/bus/vmbus/vmbus_common.c +2 -6
@@ -111,12 +111,8 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr,/* reference driver structure */ dev->driver = dr; -if (dev->device.numa_node <0 ) { -if (rte_socket_count () >1 ) -VMBUS_LOG (INFO ,"Device %s is not NUMA-aware, defaulting socket to 0" , - guid); - dev->device.numa_node =0 ; - } +if (dev->device.numa_node <0 &&rte_socket_count () >1 ) +VMBUS_LOG (INFO ,"Device %s is not NUMA-aware" , guid);/* call the driver probe() function */ VMBUS_LOG (INFO ," probe driver: %s" , dr->driver.name);
drivers/dma/idxd/idxd_bus.c +2 -1
@@ -12,6 +12,7 @@#include <dev_driver.h> #include <rte_devargs.h> #include <rte_eal.h> +#include <rte_memory.h> #include <rte_log.h> #include <rte_dmadev_pmd.h> #include <rte_string_fns.h>
@@ -322,7 +323,7 @@ dsa_scan(void)while ((wq =readdir (dev_dir)) !=NULL ) {struct rte_dsa_device *dev; -int numa_node =-1 ; +int numa_node =SOCKET_ID_ANY ;if (strncmp (wq->d_name,"wq" ,2 ) !=0 )continue ;
examples/distributor/main.c +2 -2
@@ -231,7 +231,7 @@ lcore_rx(struct lcore_params *p)if ((enabled_port_mask & (1 << port)) ==0 )continue ; -if (rte_eth_dev_socket_id (port) >0 && +if (rte_eth_dev_socket_id (port) >=0 &&rte_eth_dev_socket_id (port) != socket_id)printf ("WARNING, port %u is on remote NUMA node to " "RX thread.\n\tPerformance will not "
@@ -406,7 +406,7 @@ lcore_tx(struct rte_ring *in_r)if ((enabled_port_mask & (1 << port)) ==0 )continue ; -if (rte_eth_dev_socket_id (port) >0 && +if (rte_eth_dev_socket_id (port) >=0 &&rte_eth_dev_socket_id (port) != socket_id)printf ("WARNING, port %u is on remote NUMA node to " "TX thread.\n\tPerformance will not "
examples/flow_classify/flow_classify.c +2 -0
@@ -818,6 +818,8 @@ main(int argc, char *argv[])printf ("\nWARNING: Too many lcores enabled. Only 1 used.\n" ); socket_id =rte_eth_dev_socket_id (0 ); +if (socket_id ==SOCKET_ID_ANY ) + socket_id =rte_lcore_to_socket_id (rte_get_next_lcore (-1 ,0 ,0 ));/* Memory allocation. 8< */ size =RTE_CACHE_LINE_ROUNDUP (sizeof (struct flow_classifier_acl ));
examples/rxtx_callbacks/main.c +1 -1
@@ -249,7 +249,7 @@ lcore_main(void)uint16_t port; RTE_ETH_FOREACH_DEV(port) - if (rte_eth_dev_socket_id(port) > 0 && + if (rte_eth_dev_socket_id(port) >= 0 && rte_eth_dev_socket_id(port) != (int)rte_socket_id()) printf("WARNING, port %u is on remote NUMA node to "
lib/ethdev/rte_ethdev.h +2 -2
@@ -2445,8 +2445,8 @@ int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);* The port identifier of the Ethernet device * @return * The NUMA socket ID to which the Ethernet device is connected or -* a default of zero if the socket could not be determined. -* -1 is returned is the port_id value is out of range. +* a default of -1 (SOCKET_ID_ANY) if the socket could not be determined. +* -1 is also returned if the port_id is invalid. */ int rte_eth_dev_socket_id (uint16_t port_id);
Signature · 1 line
2.30.2
Quoted 11 lines · Olivier Matz
The
dev->device.numa_nodefield is set by each bus driver for every device it manages to indicate on which NUMA node this device lies.When this information is unknown, the assigned value is not consistent across the bus drivers.
Set the default value to
SOCKET_ID_ANY(-1) by all bus drivers when the NUMA information is unavailable. This change impactsrte_eth_dev_socket_id()in the same manner.
Quoted 8 lines
Signed-off-by Olivier Matz <[email protected]>---
v2
* useSOCKET_ID_ANYinstead of -1 indrivers/dma/idxd(David)
* document the behavior change ofrte_eth_dev_socket_id()
* fix few examples whererte_eth_dev_socket_id()was expected to return 0 on unknown socket
[snip]
Quoted 17 lines
doc/guides/rel_notes/release_22_11.rst +6
-0@@ -317,6 +317,12 @@ ABI Changes * eventdev: Added ``weight`` and ``affinity`` fields to ``rte_event_queue_conf`` structure. +* bus: Changed the device numa node to -1 when NUMA information is unavailable. + The ``dev->device.numa_node`` field is set by each bus driver for + every device it manages to indicate on which NUMA node this device lies. + When this information is unknown, the assigned value was not consistent + across the bus drivers. This similarly impacts ``rte_eth_dev_socket_id()``. + Known Issues ------------
[snip]
Quoted 5 lines
lib/ethdev/rte_ethdev.h +0
-0
lib/ethdev/rte_ethdev.h int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port); · line 2451
Quoted 9 lines
lib/ethdev/rte_ethdev.h +2
-2@@ -2445,8 +2445,8 @@ int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);* The port identifier of the Ethernet device * @return * The NUMA socket ID to which the Ethernet device is connected or -* a default of zero if the socket could not be determined. -* -1 is returned is the port_id value is out of range. +* a default of -1 (SOCKET_ID_ANY) if the socket could not be determined. +* -1 is also returned if the port_id is invalid. */ int rte_eth_dev_socket_id (uint16_t port_id);
It would be better to distinguish the two cases, using rte_errno. Something like:
lib/ethdev/rte_ethdev.c +0 -0
@@ -562,8 +562,16 @@ rte_eth_dev_owner_get(const uint16_t port_id,
struct rte_eth_dev_owner *owner)
int
rte_eth_dev_socket_id(uint16_t port_id)
{
- RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1); - return rte_eth_devices[port_id].data->numa_node; + int socket_id = SOCKET_ID_ANY;
+
+ if (!rte_eth_dev_is_valid_port(port_id))
+ rte_errno = EINVAL;
+ } else {
+ socket_id = rte_eth_devices[port_id].data->numa_node;
+ if (socket_id == SOCKET_ID_ANY)
+ rte_errno = 0;
+ }
+ return socket_id;
}
void *
lib/ethdev/rte_ethdev.h +0 -0
@@ -2444,9 +2444,11 @@ int rte_eth_hairpin_unbind(uint16_t tx_port,
uint16_t rx_port);
* @param port_id
* The port identifier of the Ethernet device
* @return
- * The NUMA socket ID to which the Ethernet device is connected or - * a default of -1 (SOCKET_ID_ANY) if the socket could not be determined. - * -1 is also returned if the port_id is invalid. + * - The NUMA socket ID which the Ethernet device is connected to. + * - -1 (which translates to SOCKET_ID_ANY) if the socket could not be + * determined. rte_errno is then set to: + * - EINVAL is the port_id is invalid, + * - 0 is the socket could not be determined,
*/
int rte_eth_dev_socket_id(uint16_t port_id);
WDYT?
Signature · 1 line
David Marchand
Hi David,
Quoted 107 lines · David Marchand
Quoted 11 lines · Olivier Matz
The
dev->device.numa_nodefield is set by each bus driver for every device it manages to indicate on which NUMA node this device lies.When this information is unknown, the assigned value is not consistent across the bus drivers.
Set the default value to
SOCKET_ID_ANY(-1) by all bus drivers when the NUMA information is unavailable. This change impactsrte_eth_dev_socket_id()in the same manner.Quoted 8 lines
Signed-off-by Olivier Matz <[email protected]>---
v2
* useSOCKET_ID_ANYinstead of -1 indrivers/dma/idxd(David)
* document the behavior change ofrte_eth_dev_socket_id()
* fix few examples whererte_eth_dev_socket_id()was expected to return 0 on unknown socketCc ethdev maintainers.[snip]
Quoted 17 lines
doc/guides/rel_notes/release_22_11.rst +6
-0@@ -317,6 +317,12 @@ ABI Changes * eventdev: Added ``weight`` and ``affinity`` fields to ``rte_event_queue_conf`` structure. +* bus: Changed the device numa node to -1 when NUMA information is unavailable. + The ``dev->device.numa_node`` field is set by each bus driver for + every device it manages to indicate on which NUMA node this device lies. + When this information is unknown, the assigned value was not consistent + across the bus drivers. This similarly impacts ``rte_eth_dev_socket_id()``. + Known Issues ------------[snip]
Quoted 5 lines
lib/ethdev/rte_ethdev.h +0
-0lib/ethdev/rte_ethdev.h int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port); · line 2451
Quoted 9 lines
lib/ethdev/rte_ethdev.h +2
-2@@ -2445,8 +2445,8 @@ int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);* The port identifier of the Ethernet device * @return * The NUMA socket ID to which the Ethernet device is connected or -* a default of zero if the socket could not be determined. -* -1 is returned is the port_id value is out of range. +* a default of -1 (SOCKET_ID_ANY) if the socket could not be determined. +* -1 is also returned if the port_id is invalid. */ int rte_eth_dev_socket_id (uint16_t port_id);It would be better to distinguish the two cases, using
rte_errno. Something like:lib/ethdev/rte_ethdev.c +10
-2@@ -562,8 +562,16 @@ rte_eth_dev_owner_get(const uint16_t port_id, struct rte_eth_dev_owner *owner)int rte_eth_dev_socket_id (uint16_t port_id) { -RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id,-1 ); -return rte_eth_devices[port_id].data->numa_node; +int socket_id =SOCKET_ID_ANY ; + +if (!rte_eth_dev_is_valid_port (port_id)) + rte_errno =EINVAL ; + } else { + socket_id = rte_eth_devices[port_id].data->numa_node; +if (socket_id ==SOCKET_ID_ANY ) + rte_errno =0 ; + } +return socket_id; }void *
lib/ethdev/rte_ethdev.h +5
-3@@ -2444,9 +2444,11 @@ int rte_eth_hairpin_unbind(uint16_t tx_port,uint16_t rx_port); * @param port_id * The port identifier of the Ethernet device * @return -* The NUMA socket ID to which the Ethernet device is connected or -* a default of -1 (SOCKET_ID_ANY) if the socket could not be determined. -* -1 is also returned if the port_id is invalid. +* - The NUMA socket ID which the Ethernet device is connected to. +* - -1 (which translates to SOCKET_ID_ANY) if the socket could not be +* determined. rte_errno is then set to: +* - EINVAL is the port_id is invalid, +* - 0 is the socket could not be determined, */ int rte_eth_dev_socket_id (uint16_t port_id);
Quoted 1 line
WDYT?
As discussed off-list, it is indeed better.
Thanks for the review
Olivier
05/10/2022 11:04, Olivier Matz:
Quoted 110 lines
Hi David,
Quoted 107 lines · David Marchand
Quoted 11 lines · Olivier Matz
The
dev->device.numa_nodefield is set by each bus driver for every device it manages to indicate on which NUMA node this device lies.When this information is unknown, the assigned value is not consistent across the bus drivers.
Set the default value to
SOCKET_ID_ANY(-1) by all bus drivers when the NUMA information is unavailable. This change impactsrte_eth_dev_socket_id()in the same manner.Quoted 8 lines
Signed-off-by Olivier Matz <[email protected]>---
v2
* useSOCKET_ID_ANYinstead of -1 indrivers/dma/idxd(David)
* document the behavior change ofrte_eth_dev_socket_id()
* fix few examples whererte_eth_dev_socket_id()was expected to return 0 on unknown socketCc ethdev maintainers.[snip]
Quoted 17 lines
doc/guides/rel_notes/release_22_11.rst +6
-0@@ -317,6 +317,12 @@ ABI Changes * eventdev: Added ``weight`` and ``affinity`` fields to ``rte_event_queue_conf`` structure. +* bus: Changed the device numa node to -1 when NUMA information is unavailable. + The ``dev->device.numa_node`` field is set by each bus driver for + every device it manages to indicate on which NUMA node this device lies. + When this information is unknown, the assigned value was not consistent + across the bus drivers. This similarly impacts ``rte_eth_dev_socket_id()``. + Known Issues ------------[snip]
Quoted 5 lines
lib/ethdev/rte_ethdev.h +0
-0lib/ethdev/rte_ethdev.h int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port); · line 2451
Quoted 9 lines
lib/ethdev/rte_ethdev.h +2
-2@@ -2445,8 +2445,8 @@ int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port);* The port identifier of the Ethernet device * @return * The NUMA socket ID to which the Ethernet device is connected or -* a default of zero if the socket could not be determined. -* -1 is returned is the port_id value is out of range. +* a default of -1 (SOCKET_ID_ANY) if the socket could not be determined. +* -1 is also returned if the port_id is invalid. */ int rte_eth_dev_socket_id (uint16_t port_id);It would be better to distinguish the two cases, using
rte_errno. Something like:lib/ethdev/rte_ethdev.c +10
-2@@ -562,8 +562,16 @@ rte_eth_dev_owner_get(const uint16_t port_id, struct rte_eth_dev_owner *owner)int rte_eth_dev_socket_id (uint16_t port_id) { -RTE_ETH_VALID_PORTID_OR_ERR_RET (port_id,-1 ); -return rte_eth_devices[port_id].data->numa_node; +int socket_id =SOCKET_ID_ANY ; + +if (!rte_eth_dev_is_valid_port (port_id)) + rte_errno =EINVAL ; + } else { + socket_id = rte_eth_devices[port_id].data->numa_node; +if (socket_id ==SOCKET_ID_ANY ) + rte_errno =0 ; + } +return socket_id; }void *
lib/ethdev/rte_ethdev.h +5
-3@@ -2444,9 +2444,11 @@ int rte_eth_hairpin_unbind(uint16_t tx_port,uint16_t rx_port); * @param port_id * The port identifier of the Ethernet device * @return -* The NUMA socket ID to which the Ethernet device is connected or -* a default of -1 (SOCKET_ID_ANY) if the socket could not be determined. -* -1 is also returned if the port_id is invalid. +* - The NUMA socket ID which the Ethernet device is connected to. +* - -1 (which translates to SOCKET_ID_ANY) if the socket could not be +* determined. rte_errno is then set to: +* - EINVAL is the port_id is invalid, +* - 0 is the socket could not be determined, */ int rte_eth_dev_socket_id (uint16_t port_id);
Quoted 3 lines
Quoted 1 line
WDYT?
As discussed off-list, it is indeed better.
+1
Note that the decision to take in case of EINVAL requires some work for each call to rte_eth_dev_socket_id(). I suppose we can leave it as a future exercise.
Quoted 11 lines · Olivier Matz
The
dev->device.numa_nodefield is set by each bus driver for every device it manages to indicate on which NUMA node this device lies.When this information is unknown, the assigned value is not consistent across the bus drivers.
Set the default value to
SOCKET_ID_ANY(-1) by all bus drivers when the NUMA information is unavailable. This change impactsrte_eth_dev_socket_id()in the same manner.
Quoted 8 lines
Signed-off-by Olivier Matz <[email protected]>---
v2
* useSOCKET_ID_ANYinstead of -1 indrivers/dma/idxd(David)
* document the behavior change ofrte_eth_dev_socket_id()
* fix few examples whererte_eth_dev_socket_id()was expected to return 0 on unknown socket
Applied with suggestion on setting rte_errno for rte_eth_dev_socket_id(). Thanks Olivier!
Signature · 1 line
David Marchand