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 <nhorman@tuxdriver.com>
This commit is contained in:
Neil Horman 2011-10-17 14:32:44 -04:00
parent cd6f20b0f5
commit a81cd26ab4
2 changed files with 17 additions and 0 deletions

11
numa.c
View file

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

View file

@ -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