From 8ae587b9ca211c97acb01fc67937169c20e04df7 Mon Sep 17 00:00:00 2001 From: Ilya Maximets Date: Mon, 25 Jan 2016 17:37:19 +0300 Subject: [PATCH] ovs-numa: Fix cpu discovering if CONFIG_NUMA disabled. 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 Signed-off-by: Ben Pfaff --- 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 693541fe7..2765ae2db 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.20.1