提交 b909e9fb 编写于 作者: A Andrea Bolognani 提交者: Peter Krempa

nodeinfo: Use nodeGetOnlineCPUBitmap() when parsing node

No need to look up the online status of each CPU separately when we
can get all the information in one go.
上级 b7b50647
...@@ -410,6 +410,7 @@ virNodeParseNode(const char *sysfs_prefix, ...@@ -410,6 +410,7 @@ virNodeParseNode(const char *sysfs_prefix,
DIR *cpudir = NULL; DIR *cpudir = NULL;
struct dirent *cpudirent = NULL; struct dirent *cpudirent = NULL;
virBitmapPtr present_cpumap = NULL; virBitmapPtr present_cpumap = NULL;
virBitmapPtr online_cpus_map = NULL;
virBitmapPtr sockets_map = NULL; virBitmapPtr sockets_map = NULL;
virBitmapPtr *cores_maps = NULL; virBitmapPtr *cores_maps = NULL;
int sock_max = 0; int sock_max = 0;
...@@ -418,7 +419,6 @@ virNodeParseNode(const char *sysfs_prefix, ...@@ -418,7 +419,6 @@ virNodeParseNode(const char *sysfs_prefix,
size_t i; size_t i;
int siblings; int siblings;
unsigned int cpu; unsigned int cpu;
int online;
int direrr; int direrr;
*threads = 0; *threads = 0;
...@@ -433,6 +433,9 @@ virNodeParseNode(const char *sysfs_prefix, ...@@ -433,6 +433,9 @@ virNodeParseNode(const char *sysfs_prefix,
present_cpumap = nodeGetPresentCPUBitmap(sysfs_prefix); present_cpumap = nodeGetPresentCPUBitmap(sysfs_prefix);
if (!present_cpumap) if (!present_cpumap)
goto cleanup; goto cleanup;
online_cpus_map = nodeGetOnlineCPUBitmap(sysfs_prefix);
if (!online_cpus_map)
goto cleanup;
/* enumerate sockets in the node */ /* enumerate sockets in the node */
if (!(sockets_map = virBitmapNew(ID_MAX + 1))) if (!(sockets_map = virBitmapNew(ID_MAX + 1)))
...@@ -445,10 +448,7 @@ virNodeParseNode(const char *sysfs_prefix, ...@@ -445,10 +448,7 @@ virNodeParseNode(const char *sysfs_prefix,
if (!virBitmapIsBitSet(present_cpumap, cpu)) if (!virBitmapIsBitSet(present_cpumap, cpu))
continue; continue;
if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0) if (!virBitmapIsBitSet(online_cpus_map, cpu))
goto cleanup;
if (!online)
continue; continue;
/* Parse socket */ /* Parse socket */
...@@ -490,10 +490,7 @@ virNodeParseNode(const char *sysfs_prefix, ...@@ -490,10 +490,7 @@ virNodeParseNode(const char *sysfs_prefix,
if (!virBitmapIsBitSet(present_cpumap, cpu)) if (!virBitmapIsBitSet(present_cpumap, cpu))
continue; continue;
if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0) if (!virBitmapIsBitSet(online_cpus_map, cpu)) {
goto cleanup;
if (!online) {
(*offline)++; (*offline)++;
continue; continue;
} }
...@@ -561,6 +558,7 @@ virNodeParseNode(const char *sysfs_prefix, ...@@ -561,6 +558,7 @@ virNodeParseNode(const char *sysfs_prefix,
virBitmapFree(cores_maps[i]); virBitmapFree(cores_maps[i]);
VIR_FREE(cores_maps); VIR_FREE(cores_maps);
virBitmapFree(sockets_map); virBitmapFree(sockets_map);
virBitmapFree(online_cpus_map);
virBitmapFree(present_cpumap); virBitmapFree(present_cpumap);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册