src/libxl/libxl_capabilities.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
From: Wim ten Have <wim.ten.have@oracle.com>
When running on a NUMA machine, populate the sibling node
and distance information using data supplied by Xen.
With locality distances information, under Xen, new host
capabilities would like:
<topology>
<cells num='4'>
<cell id='0'>
<memory unit='KiB'>263902380</memory>
<distances>
<sibling id='0' value='10'/>
<sibling id='1' value='21'/>
</distances>
...
</cell>
...
</cells>
...
</topology>
Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
---
src/libxl/libxl_capabilities.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
index 839a2ee..1702ecb 100644
--- a/src/libxl/libxl_capabilities.c
+++ b/src/libxl/libxl_capabilities.c
@@ -247,8 +247,9 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
{
libxl_numainfo *numa_info = NULL;
libxl_cputopology *cpu_topo = NULL;
- int nr_nodes = 0, nr_cpus = 0;
+ int nr_nodes = 0, nr_cpus = 0, nr_siblings = 0;
virCapsHostNUMACellCPUPtr *cpus = NULL;
+ virCapsHostNUMACellSiblingInfoPtr siblings = NULL;
int *nr_cpus_node = NULL;
size_t i;
int ret = -1;
@@ -322,10 +323,24 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
if (numa_info[i].size == LIBXL_NUMAINFO_INVALID_ENTRY)
continue;
+#ifdef LIBXL_HAVE_VNUMA
+ nr_siblings = numa_info[i].num_dists;
+ if (nr_siblings) {
+ size_t j;
+
+ if (VIR_ALLOC_N(siblings, nr_siblings) < 0)
+ goto cleanup;
+
+ for (j = 0; j < nr_siblings; j++) {
+ siblings[j].node = j;
+ siblings[j].distance = numa_info[i].dists[j];
+ }
+ }
+#endif
if (virCapabilitiesAddHostNUMACell(caps, i,
numa_info[i].size / 1024,
nr_cpus_node[i], cpus[i],
- 0, NULL,
+ nr_siblings, siblings,
0, NULL) < 0) {
virCapabilitiesClearHostNUMACellCPUTopology(cpus[i],
nr_cpus_node[i]);
@@ -343,6 +358,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
for (i = 0; cpus && i < nr_nodes; i++)
VIR_FREE(cpus[i]);
virCapabilitiesFreeNUMAInfo(caps);
+ VIR_FREE(siblings);
}
VIR_FREE(cpus);
--
2.9.3
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Wim Ten Have wrote:
> From: Wim ten Have <wim.ten.have@oracle.com>
>
> When running on a NUMA machine, populate the sibling node
> and distance information using data supplied by Xen.
>
> With locality distances information, under Xen, new host
> capabilities would like:
>
> <topology>
> <cells num='4'>
> <cell id='0'>
> <memory unit='KiB'>263902380</memory>
> <distances>
> <sibling id='0' value='10'/>
> <sibling id='1' value='21'/>
> </distances>
> ...
> </cell>
> ...
> </cells>
> ...
> </topology>
>
> Signed-off-by: Wim ten Have <wim.ten.have@oracle.com>
> ---
> src/libxl/libxl_capabilities.c | 20 ++++++++++++++++++--
> 1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c
> index 839a2ee..1702ecb 100644
> --- a/src/libxl/libxl_capabilities.c
> +++ b/src/libxl/libxl_capabilities.c
> @@ -247,8 +247,9 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
> {
> libxl_numainfo *numa_info = NULL;
> libxl_cputopology *cpu_topo = NULL;
> - int nr_nodes = 0, nr_cpus = 0;
> + int nr_nodes = 0, nr_cpus = 0, nr_siblings = 0;
> virCapsHostNUMACellCPUPtr *cpus = NULL;
> + virCapsHostNUMACellSiblingInfoPtr siblings = NULL;
> int *nr_cpus_node = NULL;
> size_t i;
> int ret = -1;
> @@ -322,10 +323,24 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
> if (numa_info[i].size == LIBXL_NUMAINFO_INVALID_ENTRY)
> continue;
>
> +#ifdef LIBXL_HAVE_VNUMA
AFAICT, this is not dependent on LIBXL_HAVE_VNUMA. The libxl_numainfo struct,
including dists and num_dists fields, was introduced in commit 97467ae4a04.
$ git describe --contains 97467ae4a04
4.2.2-rc1~433
Indeed I removed it and successfully built the patch on Xen 4.4.
Looks good otherwise, thanks!
Regards,
Jim
> + nr_siblings = numa_info[i].num_dists;
> + if (nr_siblings) {
> + size_t j;
> +
> + if (VIR_ALLOC_N(siblings, nr_siblings) < 0)
> + goto cleanup;
> +
> + for (j = 0; j < nr_siblings; j++) {
> + siblings[j].node = j;
> + siblings[j].distance = numa_info[i].dists[j];
> + }
> + }
> +#endif
> if (virCapabilitiesAddHostNUMACell(caps, i,
> numa_info[i].size / 1024,
> nr_cpus_node[i], cpus[i],
> - 0, NULL,
> + nr_siblings, siblings,
> 0, NULL) < 0) {
> virCapabilitiesClearHostNUMACellCPUTopology(cpus[i],
> nr_cpus_node[i]);
> @@ -343,6 +358,7 @@ libxlCapsInitNuma(libxl_ctx *ctx, virCapsPtr caps)
> for (i = 0; cpus && i < nr_nodes; i++)
> VIR_FREE(cpus[i]);
> virCapabilitiesFreeNUMAInfo(caps);
> + VIR_FREE(siblings);
> }
>
> VIR_FREE(cpus);
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2026 Red Hat, Inc.