提交 5ed9b3bc 编写于 作者: P Peter Krempa

nodeinfo: Get rid of nodeGetCellMemory

The function was called in a single place only and was reporting errors
that were later ignored. Use the virNumaGetNodeMemory helper to get the
size of the memory in the NUMA node and remove the helper
上级 9dd02965
......@@ -1545,8 +1545,6 @@ nodeGetFreeMemoryFake(void)
# define MASK_CPU_ISSET(mask, cpu) \
(((mask)[((cpu) / n_bits(*(mask)))] >> ((cpu) % n_bits(*(mask)))) & 1)
static unsigned long long nodeGetCellMemory(int cell);
static virBitmapPtr
virNodeGetSiblingsList(const char *dir, int cpu_id)
{
......@@ -1637,8 +1635,9 @@ nodeCapsInitNUMA(virCapsPtr caps)
continue;
}
/* Detect the amount of memory in the numa cell */
memory = nodeGetCellMemory(n);
/* Detect the amount of memory in the numa cell in KiB */
virNumaGetNodeMemory(n, &memory, NULL);
memory >>= 10;
for (ncpus = 0, i = 0; i < max_n_cpus; i++)
if (MASK_CPU_ISSET(mask, i))
......@@ -1736,46 +1735,6 @@ nodeGetFreeMemory(void)
return freeMem;
}
/**
* nodeGetCellMemory
* @cell: The number of the numa cell to get memory info for.
*
* Request size of memory in a NUMA node.
*
* Returns 0 if unavailable, amount of memory in KiB on success.
*/
static unsigned long long nodeGetCellMemory(int cell)
{
unsigned long long mem;
unsigned long long memKiB = 0;
int maxCell;
/* Make sure the provided cell number is valid. */
if ((maxCell = virNumaGetMaxNode()) < 0)
goto cleanup;
if (cell > maxCell) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cell %d out of range (0-%d)"),
cell, maxCell);
goto cleanup;
}
/* Get the amount of memory(bytes) in the node */
if (virNumaGetNodeMemory(cell, &mem, NULL) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to query NUMA total memory for node: %d"),
cell);
goto cleanup;
}
/* Convert the memory from bytes to KiB */
memKiB = mem >> 10;
cleanup:
return memKiB;
}
#else
int nodeCapsInitNUMA(virCapsPtr caps) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册