diff mbox

[odp-ovs,4/5] ovs-numa: workaround missing numa support for pmd netdevs

Message ID 1421943076-12240-5-git-send-email-ciprian.barbu@linaro.org
State New
Headers show

Commit Message

Ciprian Barbu Jan. 22, 2015, 4:11 p.m. UTC
Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org>
---
This is a workaround to make odp-ovs compile on KS2 which has no NUMA support.
It might make it as a proper fix, because the only thing needed is the list of
cpus, and the number of numa nodes can very well be 1.

 lib/ovs-numa.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/lib/ovs-numa.c b/lib/ovs-numa.c
index dabdd18..cad4bca 100644
--- a/lib/ovs-numa.c
+++ b/lib/ovs-numa.c
@@ -94,13 +94,27 @@  discover_numa_and_core(void)
 {
     int n_cpus = 0;
     int i;
+    DIR *dir;
+    char* path;
+    bool has_numa = 1;
+    int max_numa_nodes = MAX_NUMA_NODES;
+
+
+    path = xasprintf("/sys/devices/system/node");
+    dir = opendir(path);
+    free(path);
+    if (!dir) {
+        has_numa = 0;
+        max_numa_nodes = 1;
+    }
 
-    for (i = 0; i < MAX_NUMA_NODES; i++) {
-        DIR *dir;
-        char* path;
-
+    for (i = 0; i < max_numa_nodes; i++) {
         /* Constructs the path to node /sys/devices/system/nodeX. */
-        path = xasprintf("/sys/devices/system/node/node%d", i);
+        if (has_numa) {
+            path = xasprintf("/sys/devices/system/node/node%d", i);
+	} else {
+            path = xasprintf("/sys/devices/system/cpu");
+	}
         dir = opendir(path);
 
         /* Creates 'struct numa_node' if the 'dir' is non-null. */