From a81cd26ab4d4a09f3345b2b391a12ee39af676b2 Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Mon, 17 Oct 2011 14:32:44 -0400 Subject: [PATCH] Fix segfault on non-numa enabled systems If a system doesn't support numa, we have an emtpty top level of the balancing tree (and we get a null dir pointer in build_numa_nodes to boot). Fix this by checking for that null condition and adding the unspecified numa node to the list of all numa nodes. See https://bugzilla.redhat.com/show_bug.cgi?id=746159 for details Signed-off-by: Neil Horman --- numa.c | 11 +++++++++++ placement.c | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/numa.c b/numa.c index 6e00243..0d93091 100644 --- a/numa.c +++ b/numa.c @@ -84,6 +84,14 @@ void build_numa_node_list(void) DIR *dir = opendir(SYSFS_NODE_PATH); struct dirent *entry; + /* + * Add the unspecified node + */ + numa_nodes = g_list_append(numa_nodes, &unspecified_node); + + if (!dir) + return; + do { entry = readdir(dir); if (!entry) @@ -96,6 +104,9 @@ void build_numa_node_list(void) static void free_numa_node(gpointer data) { + if (data == (void *)(&unspecified_node)) + return; + free(data); } diff --git a/placement.c b/placement.c index a5b976b..113891b 100644 --- a/placement.c +++ b/placement.c @@ -45,6 +45,12 @@ static void find_best_object(struct topo_obj *d, void *data) uint64_t newload; cpumask_t subset; + /* + * Don't consider the unspecified numa node here + */ + if ((d->obj_type == OBJ_TYPE_NODE) && (d->number == -1)) + return; + /* * If the hint policy is subset, then we only want * to consider objects that are within the irqs hint, but