utils: Remove arbitrary limit on socket_id/core_id

While in most cases the values are going to be much
smaller than our arbitrary 4096 limit, there is really
no guarantee that would be the case: in fact, a few
aarch64 servers have been spotted in the wild with
core_id as high as 6216.

Take advantage of virBitmap's ability to automatically
alter its size at runtime to accomodate such values.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Andrea Bolognani 2018-08-03 10:15:16 +02:00
parent 089849d3c4
commit ba35ac2ebb

View File

@ -293,9 +293,6 @@ virHostCPUParseNode(const char *node,
int *threads,
int *offline)
{
/* Biggest value we can expect to be used as either socket id
* or core id. Bitmaps will need to be sized accordingly */
const int ID_MAX = 4095;
int ret = -1;
int processors = 0;
DIR *cpudir = NULL;
@ -324,7 +321,7 @@ virHostCPUParseNode(const char *node,
goto cleanup;
/* enumerate sockets in the node */
if (!(sockets_map = virBitmapNew(ID_MAX + 1)))
if (!(sockets_map = virBitmapNewEmpty()))
goto cleanup;
while ((direrr = virDirRead(cpudir, &cpudirent, node)) > 0) {
@ -343,14 +340,8 @@ virHostCPUParseNode(const char *node,
if (virHostCPUGetSocket(cpu, &sock) < 0)
goto cleanup;
if (sock > ID_MAX) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Socket %d can't be handled (max socket is %d)"),
sock, ID_MAX);
goto cleanup;
}
if (virBitmapSetBit(sockets_map, sock) < 0)
if (virBitmapSetBitExpand(sockets_map, sock) < 0)
goto cleanup;
if (sock > sock_max)
@ -367,7 +358,7 @@ virHostCPUParseNode(const char *node,
goto cleanup;
for (i = 0; i < sock_max; i++)
if (!(cores_maps[i] = virBitmapNew(ID_MAX + 1)))
if (!(cores_maps[i] = virBitmapNewEmpty()))
goto cleanup;
/* Iterate over all CPUs in the node, in ascending order */
@ -411,14 +402,8 @@ virHostCPUParseNode(const char *node,
if (virHostCPUGetCore(cpu, &core) < 0)
goto cleanup;
}
if (core > ID_MAX) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Core %d can't be handled (max core is %d)"),
core, ID_MAX);
goto cleanup;
}
if (virBitmapSetBit(cores_maps[sock], core) < 0)
if (virBitmapSetBitExpand(cores_maps[sock], core) < 0)
goto cleanup;
if (!(siblings = virHostCPUCountThreadSiblings(cpu)))