diff mbox

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

Message ID 1453732639-23944-1-git-send-email-i.maximets@samsung.com
State Accepted
Headers show

Commit Message

Ilya Maximets Jan. 25, 2016, 2:37 p.m. UTC
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@samsung.com>
---
 lib/ovs-numa.c | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

Comments

Ben Pfaff Feb. 6, 2016, 12:33 a.m. UTC | #1
On Mon, Jan 25, 2016 at 05:37:19PM +0300, Ilya Maximets wrote:
> 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@samsung.com>

Applied to master, thanks.
diff mbox

Patch

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