mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
virnuma: Check for numa_bitmask_isbitset presence
On some systems, libnuma can be present but it's so ancient that it misses some symbols that virNumaGetDistances() needs. To be more precise: numa_bitmask_isbitset() and numa_nodes_ptr are the symbols in question. Fortunately, they were both introduced in the same release so it's sufficient for us to check for only one of them. And the winner is numa_bitmask_isbitset(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
1919e35547
commit
9e0cbcd888
@ -19,6 +19,10 @@ dnl
|
||||
|
||||
AC_DEFUN([LIBVIRT_CHECK_NUMACTL],[
|
||||
LIBVIRT_CHECK_LIB([NUMACTL], [numa], [numa_available], [numa.h])
|
||||
AC_CHECK_LIB([numa], [numa_bitmask_isbitset], [have_numa_bitmask_isbitset=yes])
|
||||
if test "$have_numa_bitmask_isbitset" = "yes"; then
|
||||
AC_DEFINE_UNQUOTED([HAVE_NUMA_BITMASK_ISBITSET], 1, [whether numa_bitmask_isbitset is available])
|
||||
fi
|
||||
])
|
||||
|
||||
AC_DEFUN([LIBVIRT_RESULT_NUMACTL],[
|
||||
|
@ -216,61 +216,6 @@ virNumaGetMaxNode(void)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virNumaGetDistances:
|
||||
* @node: identifier of the requested NUMA node
|
||||
* @distances: array of distances to sibling nodes
|
||||
* @ndistances: size of @distances
|
||||
*
|
||||
* Get array of distances to sibling nodes from @node. If a
|
||||
* distances[x] equals to zero, the node x is not enabled or
|
||||
* doesn't exist. As a special case, if @node itself refers to
|
||||
* disabled or nonexistent NUMA node, then @distances and
|
||||
* @ndistances are set to NULL and zero respectively.
|
||||
*
|
||||
* The distances are a bit of magic. For a local node the value
|
||||
* is 10, for remote it's typically 20 meaning that time penalty
|
||||
* for accessing a remote node is two time bigger than when
|
||||
* accessing a local node.
|
||||
*
|
||||
* Returns 0 on success, -1 otherwise.
|
||||
*/
|
||||
int
|
||||
virNumaGetDistances(int node,
|
||||
int **distances,
|
||||
int *ndistances)
|
||||
{
|
||||
int ret = -1;
|
||||
int max_node;
|
||||
size_t i;
|
||||
|
||||
if (!numa_bitmask_isbitset(numa_nodes_ptr, node)) {
|
||||
VIR_DEBUG("Node %d does not exist", node);
|
||||
*distances = NULL;
|
||||
*ndistances = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((max_node = virNumaGetMaxNode()) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (VIR_ALLOC_N(*distances, max_node) < 0)
|
||||
goto cleanup;
|
||||
|
||||
*ndistances = max_node + 1;
|
||||
|
||||
for (i = 0; i<= max_node; i++) {
|
||||
if (!numa_bitmask_isbitset(numa_nodes_ptr, i))
|
||||
continue;
|
||||
|
||||
(*distances)[i] = numa_distance(node, i);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* virNumaGetNodeMemory:
|
||||
* @node: identifier of the requested NUMA node
|
||||
@ -443,17 +388,6 @@ virNumaGetNodeCPUs(int node ATTRIBUTE_UNUSED,
|
||||
_("NUMA isn't available on this host"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
virNumaGetDistances(int node ATTRIBUTE_UNUSED,
|
||||
int **distances,
|
||||
int *ndistances)
|
||||
{
|
||||
*distances = NULL;
|
||||
*ndistances = 0;
|
||||
VIR_DEBUG("NUMA isn't available on this host");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -469,3 +403,72 @@ virNumaGetMaxCPUs(void)
|
||||
{
|
||||
return NUMA_MAX_N_CPUS;
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_NUMA_BITMASK_ISBITSET
|
||||
/**
|
||||
* virNumaGetDistances:
|
||||
* @node: identifier of the requested NUMA node
|
||||
* @distances: array of distances to sibling nodes
|
||||
* @ndistances: size of @distances
|
||||
*
|
||||
* Get array of distances to sibling nodes from @node. If a
|
||||
* distances[x] equals to zero, the node x is not enabled or
|
||||
* doesn't exist. As a special case, if @node itself refers to
|
||||
* disabled or nonexistent NUMA node, then @distances and
|
||||
* @ndistances are set to NULL and zero respectively.
|
||||
*
|
||||
* The distances are a bit of magic. For a local node the value
|
||||
* is 10, for remote it's typically 20 meaning that time penalty
|
||||
* for accessing a remote node is two time bigger than when
|
||||
* accessing a local node.
|
||||
*
|
||||
* Returns 0 on success, -1 otherwise.
|
||||
*/
|
||||
int
|
||||
virNumaGetDistances(int node,
|
||||
int **distances,
|
||||
int *ndistances)
|
||||
{
|
||||
int ret = -1;
|
||||
int max_node;
|
||||
size_t i;
|
||||
|
||||
if (!numa_bitmask_isbitset(numa_nodes_ptr, node)) {
|
||||
VIR_DEBUG("Node %d does not exist", node);
|
||||
*distances = NULL;
|
||||
*ndistances = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((max_node = virNumaGetMaxNode()) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (VIR_ALLOC_N(*distances, max_node) < 0)
|
||||
goto cleanup;
|
||||
|
||||
*ndistances = max_node + 1;
|
||||
|
||||
for (i = 0; i<= max_node; i++) {
|
||||
if (!numa_bitmask_isbitset(numa_nodes_ptr, i))
|
||||
continue;
|
||||
|
||||
(*distances)[i] = numa_distance(node, i);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
int
|
||||
virNumaGetDistances(int node ATTRIBUTE_UNUSED,
|
||||
int **distances,
|
||||
int *ndistances)
|
||||
{
|
||||
*distances = NULL;
|
||||
*ndistances = 0;
|
||||
VIR_DEBUG("NUMA distance information isn't availble on this host");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user