[libvirt] [PATCH 3/4] util: Introduce virNumaNodesetToCPUset()
Ján Tomko
jtomko at redhat.com
Mon Jun 3 12:13:13 UTC 2019
On Fri, May 31, 2019 at 05:22:01PM +0200, Andrea Bolognani wrote:
>This helper converts a set of NUMA node to the set of CPUs
>they contain.
>
>Signed-off-by: Andrea Bolognani <abologna at redhat.com>
>---
> src/libvirt_private.syms | 1 +
> src/util/virnuma.c | 55 ++++++++++++++++++++++++++++++++++++++++
> src/util/virnuma.h | 2 ++
> 3 files changed, 58 insertions(+)
>
>diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
>index 678d0348a2..3553545504 100644
>--- a/src/libvirt_private.syms
>+++ b/src/libvirt_private.syms
>@@ -2556,6 +2556,7 @@ virNumaGetPages;
> virNumaIsAvailable;
> virNumaNodeIsAvailable;
> virNumaNodesetIsAvailable;
>+virNumaNodesetToCPUset;
> virNumaSetPagePoolSize;
> virNumaSetupMemoryPolicy;
>
>diff --git a/src/util/virnuma.c b/src/util/virnuma.c
>index dd3fb7519e..9f9f149f0a 100644
>--- a/src/util/virnuma.c
>+++ b/src/util/virnuma.c
>@@ -297,6 +297,49 @@ virNumaGetNodeCPUs(int node,
> # undef MASK_CPU_ISSET
> # undef n_bits
>
>+/**
>+ * virNumaNodesetToCPUset:
>+ * @nodeset: bitmap containing a set of NUMA nodes
>+ * @cpuset: return location for a bitmap containing a set of CPUs
>+ *
>+ * Convert a set of NUMA node to the set of CPUs they contain.
>+ *
>+ * Returns 0 on success, <0 on failure.
>+ */
>+int
>+virNumaNodesetToCPUset(virBitmapPtr nodeset,
>+ virBitmapPtr *cpuset)
I'd prefer the output argument to be first - see VIR_STRDUP.
But I have no stats about which style is prevailing.
>+{
>+ VIR_AUTOPTR(virBitmap) allNodesCPUs = NULL;
>+ size_t nodesetSize;
>+ size_t i;
>+
>+ *cpuset = NULL;
>+
>+ if (!nodeset)
>+ return 0;
>+
>+ allNodesCPUs = virBitmapNewEmpty();
>+ nodesetSize = virBitmapSize(nodeset);
>+
>+ for (i = 0; i < nodesetSize; i++) {
>+ VIR_AUTOPTR(virBitmap) nodeCPUs = NULL;
>+
>+ if (!virBitmapIsBitSet(nodeset, i))
>+ continue;
>+
>+ if (virNumaGetNodeCPUs(i, &nodeCPUs) < 0)
>+ return -1;
>+
>+ if (virBitmapUnion(allNodesCPUs, nodeCPUs) < 0)
>+ return -1;
>+ }
>+
>+ VIR_STEAL_PTR(*cpuset, allNodesCPUs);
>+
>+ return 0;
>+}
>+
> #else /* !WITH_NUMACTL */
>
> int
>@@ -351,6 +394,18 @@ virNumaGetNodeCPUs(int node ATTRIBUTE_UNUSED,
> _("NUMA isn't available on this host"));
> return -1;
> }
>+
>+int
>+virNumaNodesetToCPUset(virBitmapPtr nodeset,
>+ virBitmapPtr *cpuset)
>+{
util/virnuma.c:399:37: error: unused parameter 'nodeset' [-Werror,-Wunused-parameter]
virNumaNodesetToCPUset(virBitmapPtr nodeset,
^
1 error generated.
>+ *cpuset = NULL;
>+
>+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>+ _("NUMA isn't available on this host"));
>+ return -1;
>+}
>+
> #endif /* !WITH_NUMACTL */
>
Reviewed-by: Ján Tomko <jtomko at redhat.com>
Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190603/bdb96a5c/attachment-0001.sig>
More information about the libvir-list
mailing list