nodeinfo: Don't fail on non-contiguous NUMA topologies

nodeGetFreeMemory and nodeGetCellsFreeMemory assumed that the NUMA nodes
are contiguous and starting from 0. Unfortunately there are machines
that don't match this assumption:

available: 1 nodes (1)
node 1 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
node 1 size: 16340 MB
node 1 free: 11065 MB

Before this patch:
error: internal error Failed to query NUMA free memory
error: internal error Failed to query NUMA free memory for node: 0

After this patch:
Total: 15772580 KiB
0: 0 KiB

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
hejia hejia 2013-07-08 22:03:05 +08:00 committed by Peter Krempa
parent ee777e9949
commit 6d986d9918

View File

@ -1686,12 +1686,9 @@ nodeGetCellsFreeMemory(unsigned long long *freeMems,
for (numCells = 0, n = startCell; n <= lastCell; n++) { for (numCells = 0, n = startCell; n <= lastCell; n++) {
long long mem; long long mem;
if (numa_node_size64(n, &mem) < 0) { if (numa_node_size64(n, &mem) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, mem = 0;
_("Failed to query NUMA free memory for node: %d"),
n);
goto cleanup;
}
freeMems[numCells++] = mem; freeMems[numCells++] = mem;
} }
ret = numCells; ret = numCells;
@ -1712,15 +1709,12 @@ nodeGetFreeMemory(void)
for (n = 0; n <= numa_max_node(); n++) { for (n = 0; n <= numa_max_node(); n++) {
long long mem; long long mem;
if (numa_node_size64(n, &mem) < 0) { if (numa_node_size64(n, &mem) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR, continue;
"%s", _("Failed to query NUMA free memory"));
goto cleanup;
}
freeMem += mem; freeMem += mem;
} }
cleanup:
return freeMem; return freeMem;
} }