mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-26 22:45:17 +00:00
nodeinfo: fix to parse present cpus rather than possible cpus
This patch resolves a situation where a core is defective and is not in the present mask during boot. Optionally a host can have empty sockets could be brought online if the socket is added. In this case the present mask contains the cpu's that are actually there in the sockets even though they might be offline for some reason. This patch excludes the cpu's that are offline because the socket is defective/empty by checking the present mask before reading the cpu directory. Otherwise, the nodeinfo on such hosts always displays wrong output which includes the defective/empty sockets as set of offline cpu's. Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
This commit is contained in:
parent
c71f0654fc
commit
bb31f4532b
@ -43,6 +43,7 @@
|
|||||||
#include "c-ctype.h"
|
#include "c-ctype.h"
|
||||||
#include "viralloc.h"
|
#include "viralloc.h"
|
||||||
#include "nodeinfopriv.h"
|
#include "nodeinfopriv.h"
|
||||||
|
#include "nodeinfo.h"
|
||||||
#include "physmem.h"
|
#include "physmem.h"
|
||||||
#include "virerror.h"
|
#include "virerror.h"
|
||||||
#include "count-one-bits.h"
|
#include "count-one-bits.h"
|
||||||
@ -403,20 +404,23 @@ CPU_COUNT(cpu_set_t *set)
|
|||||||
/* parses a node entry, returning number of processors in the node and
|
/* parses a node entry, returning number of processors in the node and
|
||||||
* filling arguments */
|
* filling arguments */
|
||||||
static int
|
static int
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3)
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
|
||||||
ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5)
|
ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5)
|
||||||
ATTRIBUTE_NONNULL(6)
|
ATTRIBUTE_NONNULL(6) ATTRIBUTE_NONNULL(7)
|
||||||
virNodeParseNode(const char *node,
|
virNodeParseNode(const char *sysfs_prefix,
|
||||||
|
const char *node,
|
||||||
virArch arch,
|
virArch arch,
|
||||||
int *sockets,
|
int *sockets,
|
||||||
int *cores,
|
int *cores,
|
||||||
int *threads,
|
int *threads,
|
||||||
int *offline)
|
int *offline)
|
||||||
{
|
{
|
||||||
|
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SYSTEM_PATH;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int processors = 0;
|
int processors = 0;
|
||||||
DIR *cpudir = NULL;
|
DIR *cpudir = NULL;
|
||||||
struct dirent *cpudirent = NULL;
|
struct dirent *cpudirent = NULL;
|
||||||
|
virBitmapPtr present_cpumap = NULL;
|
||||||
int sock_max = 0;
|
int sock_max = 0;
|
||||||
cpu_set_t sock_map;
|
cpu_set_t sock_map;
|
||||||
int sock;
|
int sock;
|
||||||
@ -437,12 +441,17 @@ virNodeParseNode(const char *node,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
present_cpumap = nodeGetPresentCPUBitmap(prefix);
|
||||||
|
|
||||||
/* enumerate sockets in the node */
|
/* enumerate sockets in the node */
|
||||||
CPU_ZERO(&sock_map);
|
CPU_ZERO(&sock_map);
|
||||||
while ((direrr = virDirRead(cpudir, &cpudirent, node)) > 0) {
|
while ((direrr = virDirRead(cpudir, &cpudirent, node)) > 0) {
|
||||||
if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
|
if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (present_cpumap && !(virBitmapIsBitSet(present_cpumap, cpu)))
|
||||||
|
continue;
|
||||||
|
|
||||||
if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0)
|
if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -476,6 +485,9 @@ virNodeParseNode(const char *node,
|
|||||||
if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
|
if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (present_cpumap && !(virBitmapIsBitSet(present_cpumap, cpu)))
|
||||||
|
continue;
|
||||||
|
|
||||||
if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0)
|
if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -536,6 +548,7 @@ virNodeParseNode(const char *node,
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
VIR_FREE(core_maps);
|
VIR_FREE(core_maps);
|
||||||
|
virBitmapFree(present_cpumap);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -657,7 +670,7 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
|
|||||||
sysfs_dir, nodedirent->d_name) < 0)
|
sysfs_dir, nodedirent->d_name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((cpus = virNodeParseNode(sysfs_cpudir, arch,
|
if ((cpus = virNodeParseNode(sysfs_dir, sysfs_cpudir, arch,
|
||||||
&socks, &cores,
|
&socks, &cores,
|
||||||
&threads, &offline)) < 0)
|
&threads, &offline)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -688,7 +701,7 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
|
|||||||
if (virAsprintf(&sysfs_cpudir, "%s/cpu", sysfs_dir) < 0)
|
if (virAsprintf(&sysfs_cpudir, "%s/cpu", sysfs_dir) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((cpus = virNodeParseNode(sysfs_cpudir, arch,
|
if ((cpus = virNodeParseNode(sysfs_dir, sysfs_cpudir, arch,
|
||||||
&socks, &cores,
|
&socks, &cores,
|
||||||
&threads, &offline)) < 0)
|
&threads, &offline)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user