Skip to contentSkip to conversation

bus/pci: fix numa node return value

PATCH Applied Pallavi Kadam 4 participants 4 messages Sep 22, 2021 – Sep 24, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bus/pci: fix numa node return value

On older CPUs, currently numa_node returns value only for socket 0. Instead, application should be able to make correct decision and also to keep consistent with the Linux code,
replace the return value to -1.

Fixes ac7c98d04f2c ("bus/pci: ignore missing NUMA node on Windows")
---
 drivers/bus/pci/windows/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/bus/pci/windows/pci.c +2 -1
index d39a7748b8..343ef6f33b 100644
@@ -5,6 +5,7 @@
 #include <rte_errno.h>
 #include <rte_log.h>
 #include <rte_eal.h>
+#include <rte_memory.h>
 
 #include "private.h"
 #include "pci_netuio.h"
@@ -243,7 +244,7 @@ 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;
+			dev->device.numa_node = SOCKET_ID_ANY;
 			return ERROR_SUCCESS;
 		}
 		RTE_LOG_WIN32_ERR("SetupDiGetDevicePropertyW"
Signature · 1 line
2.31.1.windows.1
Acked-by on v1 1/1
#1 lore raw
Quoted 41 lines

Subject: [PATCH] bus/pci: fix numa node return value

External email: Use caution opening links or attachments

On older CPUs, currently numa_node returns value only for socket 0. Instead, application should be able to make correct decision and also to keep consistent with the Linux code, replace the return value to -1.

Fixes ac7c98d04f2c ("bus/pci: ignore missing NUMA node on Windows")
---
 drivers/bus/pci/windows/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/bus/pci/windows/pci.c +2 -2
index d39a7748b8..343ef6f33b 100644
@@ -5,6 +5,7 @@
 #include <rte_errno.h>
 #include <rte_log.h>
 #include <rte_eal.h>
+#include <rte_memory.h>
 
 #include "private.h"
 #include "pci_netuio.h"
@@ -243,7 +244,7 @@ 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;
+                       dev->device.numa_node = SOCKET_ID_ANY;
                        return ERROR_SUCCESS;
                }
                RTE_LOG_WIN32_ERR("SetupDiGetDevicePropertyW"
--
Quoted 1 line

2.31.1.windows.1

You should add "on Windows" to the end of the patch name to clarity it's a Windows issue.

Aside from that LGTM.

#2 lore raw

23/09/2021 17:44, Tal Shnaiderman:

Quoted 6 lines
Quoted 6 lines

Subject: [PATCH] bus/pci: fix numa node return value

On older CPUs, currently numa_node returns value only for socket 0. Instead, application should be able to make correct decision and also to keep consistent with the Linux code, replace the return value to -1.

Quoted 8 lines
Quoted 6 lines
Fixes ac7c98d04f2c ("bus/pci: ignore missing NUMA node on Windows")

Applied, thanks

#3 lore raw
In reply to Pallavi Kadam

Hi Pallavi,

Assuming the intention is set SOCKET_ID_ANY for faulty cases, couple of observation. In Linux

```
        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;
        }
```

[snipped]

drivers/bus/pci/windows/pci.c get_device_resource_info(HDEVINFO dev_info, · line 244

Quoted 2 lines
drivers/bus/pci/windows/pci.c +0 -0
@@ -243,7 +244,7 @@ get_device_resource_info(HDEVINFO dev_info,
 		DWORD error = GetLastError();

Set the default value as dev->device.numa_node = SOCKET_ID_ANY;

drivers/bus/pci/windows/pci.c get_device_resource_info(HDEVINFO dev_info, · line 247

Quoted 5 lines
(quoted diff) +0 -0
 		if (error == ERROR_NOT_FOUND) {
 			/* On older CPUs, NUMA is not bound to PCIe

locality. */

drivers/bus/pci/windows/pci.c +1 -1
-			dev->device.numa_node = 0;
+			dev->device.numa_node = SOCKET_ID_ANY;

If the API is unsuccessful for ERROR_NOT_FOUND then you can set it to 0 (as recommened in documentation)

drivers/bus/pci/windows/pci.c get_device_resource_info(HDEVINFO dev_info, · line 250

Quoted 3 lines
drivers/bus/pci/windows/pci.c +0 -0
 			return ERROR_SUCCESS;
 		}
 		RTE_LOG_WIN32_ERR("SetupDiGetDevicePropertyW"

Else if if it other errors it will SOCKET_ID_ANY.

Quoted 2 lines

--
2.31.1.windows.1