|
|
c480ed |
From e624d2040a5a8e16e670accc52e110393d9fb2b8 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <e624d2040a5a8e16e670accc52e110393d9fb2b8@dist-git>
|
|
|
c480ed |
From: Andrea Bolognani <abologna@redhat.com>
|
|
|
c480ed |
Date: Tue, 11 Jun 2019 10:55:02 +0200
|
|
|
c480ed |
Subject: [PATCH] util: Introduce virNumaNodesetToCPUset()
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
This helper converts a set of NUMA node to the set of CPUs
|
|
|
c480ed |
they contain.
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 2d2b26f96fed1e95dd4495168cee73c5c4092634)
|
|
|
c480ed |
|
|
|
c480ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1716908
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
c480ed |
Message-Id: <20190611085506.12564-3-abologna@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/libvirt_private.syms | 1 +
|
|
|
c480ed |
src/util/virnuma.c | 55 ++++++++++++++++++++++++++++++++++++++++
|
|
|
c480ed |
src/util/virnuma.h | 2 ++
|
|
|
c480ed |
3 files changed, 58 insertions(+)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
c480ed |
index 05c96c29e2..7c48908a54 100644
|
|
|
c480ed |
--- a/src/libvirt_private.syms
|
|
|
c480ed |
+++ b/src/libvirt_private.syms
|
|
|
c480ed |
@@ -2485,6 +2485,7 @@ virNumaGetPages;
|
|
|
c480ed |
virNumaIsAvailable;
|
|
|
c480ed |
virNumaNodeIsAvailable;
|
|
|
c480ed |
virNumaNodesetIsAvailable;
|
|
|
c480ed |
+virNumaNodesetToCPUset;
|
|
|
c480ed |
virNumaSetPagePoolSize;
|
|
|
c480ed |
virNumaSetupMemoryPolicy;
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
|
|
|
c480ed |
index fd15714553..75f80dcd30 100644
|
|
|
c480ed |
--- a/src/util/virnuma.c
|
|
|
c480ed |
+++ b/src/util/virnuma.c
|
|
|
c480ed |
@@ -311,6 +311,49 @@ virNumaGetNodeCPUs(int node,
|
|
|
c480ed |
# undef MASK_CPU_ISSET
|
|
|
c480ed |
# undef n_bits
|
|
|
c480ed |
|
|
|
c480ed |
+/**
|
|
|
c480ed |
+ * virNumaNodesetToCPUset:
|
|
|
c480ed |
+ * @nodeset: bitmap containing a set of NUMA nodes
|
|
|
c480ed |
+ * @cpuset: return location for a bitmap containing a set of CPUs
|
|
|
c480ed |
+ *
|
|
|
c480ed |
+ * Convert a set of NUMA node to the set of CPUs they contain.
|
|
|
c480ed |
+ *
|
|
|
c480ed |
+ * Returns 0 on success, <0 on failure.
|
|
|
c480ed |
+ */
|
|
|
c480ed |
+int
|
|
|
c480ed |
+virNumaNodesetToCPUset(virBitmapPtr nodeset,
|
|
|
c480ed |
+ virBitmapPtr *cpuset)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOPTR(virBitmap) allNodesCPUs = NULL;
|
|
|
c480ed |
+ size_t nodesetSize;
|
|
|
c480ed |
+ size_t i;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ *cpuset = NULL;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!nodeset)
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ allNodesCPUs = virBitmapNewEmpty();
|
|
|
c480ed |
+ nodesetSize = virBitmapSize(nodeset);
|
|
|
c480ed |
+
|
|
|
c480ed |
+ for (i = 0; i < nodesetSize; i++) {
|
|
|
c480ed |
+ VIR_AUTOPTR(virBitmap) nodeCPUs = NULL;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!virBitmapIsBitSet(nodeset, i))
|
|
|
c480ed |
+ continue;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virNumaGetNodeCPUs(i, &nodeCPUs) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virBitmapUnion(allNodesCPUs, nodeCPUs) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ VIR_STEAL_PTR(*cpuset, allNodesCPUs);
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
#else /* !WITH_NUMACTL */
|
|
|
c480ed |
|
|
|
c480ed |
int
|
|
|
c480ed |
@@ -365,6 +408,18 @@ virNumaGetNodeCPUs(int node ATTRIBUTE_UNUSED,
|
|
|
c480ed |
_("NUMA isn't available on this host"));
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
}
|
|
|
c480ed |
+
|
|
|
c480ed |
+int
|
|
|
c480ed |
+virNumaNodesetToCPUset(virBitmapPtr nodeset ATTRIBUTE_UNUSED,
|
|
|
c480ed |
+ virBitmapPtr *cpuset)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ *cpuset = NULL;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
c480ed |
+ _("NUMA isn't available on this host"));
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
#endif /* !WITH_NUMACTL */
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
diff --git a/src/util/virnuma.h b/src/util/virnuma.h
|
|
|
c480ed |
index a3ffb6d6c7..df7911db4e 100644
|
|
|
c480ed |
--- a/src/util/virnuma.h
|
|
|
c480ed |
+++ b/src/util/virnuma.h
|
|
|
c480ed |
@@ -48,6 +48,8 @@ int virNumaGetNodeMemory(int node,
|
|
|
c480ed |
unsigned int virNumaGetMaxCPUs(void);
|
|
|
c480ed |
|
|
|
c480ed |
int virNumaGetNodeCPUs(int node, virBitmapPtr *cpus) ATTRIBUTE_NOINLINE;
|
|
|
c480ed |
+int virNumaNodesetToCPUset(virBitmapPtr nodeset,
|
|
|
c480ed |
+ virBitmapPtr *cpuset);
|
|
|
c480ed |
|
|
|
c480ed |
int virNumaGetPageInfo(int node,
|
|
|
c480ed |
unsigned int page_size,
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|