[ovs-dev] [PATCH] ovs-numa: Fix cpu discovering if CONFIG_NUMA disabled.

Ilya Maximets i.maximets at samsung.com
Mon Jan 25 14:37:19 UTC 2016


If CONFIG_NUMA disabled in the system, PMD threads can't
be created:

|ovs_numa|INFO|Discovered 0 NUMA nodes and 0 CPU cores

Signed-off-by: Ilya Maximets <i.maximets at samsung.com>
---
 lib/ovs-numa.c | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/lib/ovs-numa.c b/lib/ovs-numa.c
index 693541f..2765ae2 100644
--- a/lib/ovs-numa.c
+++ b/lib/ovs-numa.c
@@ -96,13 +96,29 @@ discover_numa_and_core(void)
 {
     int n_cpus = 0;
     int i;
+    DIR *dir;
+    bool numa_supported = true;
+
+    /* Check if NUMA supported on this system. */
+    dir = opendir("/sys/devices/system/node");
+
+    if (!dir && errno == ENOENT) {
+        numa_supported = false;
+    }
+    if (dir) {
+        closedir(dir);
+    }
 
     for (i = 0; i < MAX_NUMA_NODES; i++) {
-        DIR *dir;
         char* path;
 
-        /* Constructs the path to node /sys/devices/system/nodeX. */
-        path = xasprintf("/sys/devices/system/node/node%d", i);
+        if (numa_supported) {
+            /* Constructs the path to node /sys/devices/system/nodeX. */
+            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. */
@@ -132,14 +148,14 @@ discover_numa_and_core(void)
             }
             VLOG_INFO("Discovered %"PRIuSIZE" CPU cores on NUMA node %d",
                       list_size(&n->cores), n->numa_id);
-            free(path);
             closedir(dir);
-        } else {
-            if (errno != ENOENT) {
-                VLOG_WARN("opendir(%s) failed (%s)", path,
-                          ovs_strerror(errno));
-            }
-            free(path);
+        } else if (errno != ENOENT) {
+            VLOG_WARN("opendir(%s) failed (%s)", path,
+                      ovs_strerror(errno));
+        }
+
+        free(path);
+        if (!dir || !numa_supported) {
             break;
         }
     }
-- 
2.5.0




More information about the dev mailing list