|
|
79b470 |
From f2670434261a395acfe97a9bd93bd55c6b3fb1f2 Mon Sep 17 00:00:00 2001
|
|
|
79b470 |
Message-Id: <f2670434261a395acfe97a9bd93bd55c6b3fb1f2@dist-git>
|
|
|
79b470 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
79b470 |
Date: Wed, 7 Oct 2020 18:45:41 +0200
|
|
|
79b470 |
Subject: [PATCH] numa: expose HMAT APIs
|
|
|
79b470 |
MIME-Version: 1.0
|
|
|
79b470 |
Content-Type: text/plain; charset=UTF-8
|
|
|
79b470 |
Content-Transfer-Encoding: 8bit
|
|
|
79b470 |
|
|
|
79b470 |
These APIs will be used by QEMU driver when building the command
|
|
|
79b470 |
line.
|
|
|
79b470 |
|
|
|
79b470 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
79b470 |
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
|
|
|
79b470 |
(cherry picked from commit 11d8ca9794e80224d0634d67da86a20380c22ab5)
|
|
|
79b470 |
|
|
|
79b470 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1749518
|
|
|
79b470 |
|
|
|
79b470 |
Conflicts:
|
|
|
79b470 |
- src/conf/numa_conf.c:
|
|
|
79b470 |
- src/conf/numa_conf.h: Both are context.
|
|
|
79b470 |
|
|
|
79b470 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
79b470 |
Message-Id: <ad394e2359bfbbff4c9d61ac2bf5faca1eba5943.1602087923.git.mprivozn@redhat.com>
|
|
|
79b470 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
79b470 |
---
|
|
|
79b470 |
src/conf/numa_conf.c | 139 +++++++++++++++++++++++++++++++++++++++
|
|
|
79b470 |
src/conf/numa_conf.h | 28 ++++++++
|
|
|
79b470 |
src/libvirt_private.syms | 6 ++
|
|
|
79b470 |
3 files changed, 173 insertions(+)
|
|
|
79b470 |
|
|
|
79b470 |
diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
|
|
|
79b470 |
index c90fb01bb6..277a695d84 100644
|
|
|
79b470 |
--- a/src/conf/numa_conf.c
|
|
|
79b470 |
+++ b/src/conf/numa_conf.c
|
|
|
79b470 |
@@ -1800,3 +1800,142 @@ virDomainNumaGetMemorySize(virDomainNumaPtr numa)
|
|
|
79b470 |
|
|
|
79b470 |
return ret;
|
|
|
79b470 |
}
|
|
|
79b470 |
+
|
|
|
79b470 |
+
|
|
|
79b470 |
+bool
|
|
|
79b470 |
+virDomainNumaHasHMAT(const virDomainNuma *numa)
|
|
|
79b470 |
+{
|
|
|
79b470 |
+ size_t i;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (!numa)
|
|
|
79b470 |
+ return false;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (numa->ninterconnects)
|
|
|
79b470 |
+ return true;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ for (i = 0; i < numa->nmem_nodes; i++) {
|
|
|
79b470 |
+ if (numa->mem_nodes[i].ncaches)
|
|
|
79b470 |
+ return true;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+
|
|
|
79b470 |
+ return false;
|
|
|
79b470 |
+}
|
|
|
79b470 |
+
|
|
|
79b470 |
+
|
|
|
79b470 |
+size_t
|
|
|
79b470 |
+virDomainNumaGetNodeCacheCount(const virDomainNuma *numa,
|
|
|
79b470 |
+ size_t node)
|
|
|
79b470 |
+{
|
|
|
79b470 |
+ if (!numa || node >= numa->nmem_nodes)
|
|
|
79b470 |
+ return 0;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ return numa->mem_nodes[node].ncaches;
|
|
|
79b470 |
+}
|
|
|
79b470 |
+
|
|
|
79b470 |
+
|
|
|
79b470 |
+int
|
|
|
79b470 |
+virDomainNumaGetNodeCache(const virDomainNuma *numa,
|
|
|
79b470 |
+ size_t node,
|
|
|
79b470 |
+ size_t cache,
|
|
|
79b470 |
+ unsigned int *level,
|
|
|
79b470 |
+ unsigned int *size,
|
|
|
79b470 |
+ unsigned int *line,
|
|
|
79b470 |
+ virDomainCacheAssociativity *associativity,
|
|
|
79b470 |
+ virDomainCachePolicy *policy)
|
|
|
79b470 |
+{
|
|
|
79b470 |
+ const virDomainNumaNode *cell;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (!numa || node >= numa->nmem_nodes)
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ cell = &numa->mem_nodes[node];
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (cache >= cell->ncaches)
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ *level = cell->caches[cache].level;
|
|
|
79b470 |
+ *size = cell->caches[cache].size;
|
|
|
79b470 |
+ *line = cell->caches[cache].line;
|
|
|
79b470 |
+ *associativity = cell->caches[cache].associativity;
|
|
|
79b470 |
+ *policy = cell->caches[cache].policy;
|
|
|
79b470 |
+ return 0;
|
|
|
79b470 |
+}
|
|
|
79b470 |
+
|
|
|
79b470 |
+
|
|
|
79b470 |
+ssize_t
|
|
|
79b470 |
+virDomainNumaGetNodeInitiator(const virDomainNuma *numa,
|
|
|
79b470 |
+ size_t node)
|
|
|
79b470 |
+{
|
|
|
79b470 |
+ size_t i;
|
|
|
79b470 |
+ unsigned int maxBandwidth = 0;
|
|
|
79b470 |
+ ssize_t candidateBandwidth = -1;
|
|
|
79b470 |
+ unsigned int minLatency = UINT_MAX;
|
|
|
79b470 |
+ ssize_t candidateLatency = -1;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (!numa || node >= numa->nmem_nodes)
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ for (i = 0; i < numa->ninterconnects; i++) {
|
|
|
79b470 |
+ const virDomainNumaInterconnect *l = &numa->interconnects[i];
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (l->target != node)
|
|
|
79b470 |
+ continue;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ switch (l->type) {
|
|
|
79b470 |
+ case VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_LATENCY:
|
|
|
79b470 |
+ if (l->value < minLatency) {
|
|
|
79b470 |
+ minLatency = l->value;
|
|
|
79b470 |
+ candidateLatency = l->initiator;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+ break;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ case VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_BANDWIDTH:
|
|
|
79b470 |
+ if (l->value > maxBandwidth) {
|
|
|
79b470 |
+ maxBandwidth = l->value;
|
|
|
79b470 |
+ candidateBandwidth = l->initiator;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+ break;
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+ }
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (candidateLatency >= 0)
|
|
|
79b470 |
+ return candidateLatency;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ return candidateBandwidth;
|
|
|
79b470 |
+}
|
|
|
79b470 |
+
|
|
|
79b470 |
+
|
|
|
79b470 |
+size_t
|
|
|
79b470 |
+virDomainNumaGetInterconnectsCount(const virDomainNuma *numa)
|
|
|
79b470 |
+{
|
|
|
79b470 |
+ if (!numa)
|
|
|
79b470 |
+ return 0;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ return numa->ninterconnects;
|
|
|
79b470 |
+}
|
|
|
79b470 |
+
|
|
|
79b470 |
+
|
|
|
79b470 |
+int
|
|
|
79b470 |
+virDomainNumaGetInterconnect(const virDomainNuma *numa,
|
|
|
79b470 |
+ size_t i,
|
|
|
79b470 |
+ virDomainNumaInterconnectType *type,
|
|
|
79b470 |
+ unsigned int *initiator,
|
|
|
79b470 |
+ unsigned int *target,
|
|
|
79b470 |
+ unsigned int *cache,
|
|
|
79b470 |
+ virDomainMemoryLatency *accessType,
|
|
|
79b470 |
+ unsigned long *value)
|
|
|
79b470 |
+{
|
|
|
79b470 |
+ const virDomainNumaInterconnect *l;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ if (!numa || i >= numa->ninterconnects)
|
|
|
79b470 |
+ return -1;
|
|
|
79b470 |
+
|
|
|
79b470 |
+ l = &numa->interconnects[i];
|
|
|
79b470 |
+ *type = l->type;
|
|
|
79b470 |
+ *initiator = l->initiator;
|
|
|
79b470 |
+ *target = l->target;
|
|
|
79b470 |
+ *cache = l->cache;
|
|
|
79b470 |
+ *accessType = l->accessType;
|
|
|
79b470 |
+ *value = l->value;
|
|
|
79b470 |
+ return 0;
|
|
|
79b470 |
+}
|
|
|
79b470 |
diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h
|
|
|
79b470 |
index 2963004c94..63843a1cc6 100644
|
|
|
79b470 |
--- a/src/conf/numa_conf.h
|
|
|
79b470 |
+++ b/src/conf/numa_conf.h
|
|
|
79b470 |
@@ -220,3 +220,31 @@ int virDomainNumaDefFormatXML(virBufferPtr buf, virDomainNumaPtr def);
|
|
|
79b470 |
int virDomainNumaDefValidate(const virDomainNuma *def);
|
|
|
79b470 |
|
|
|
79b470 |
unsigned int virDomainNumaGetCPUCountTotal(virDomainNumaPtr numa);
|
|
|
79b470 |
+
|
|
|
79b470 |
+bool virDomainNumaHasHMAT(const virDomainNuma *numa);
|
|
|
79b470 |
+
|
|
|
79b470 |
+size_t virDomainNumaGetNodeCacheCount(const virDomainNuma *numa,
|
|
|
79b470 |
+ size_t node);
|
|
|
79b470 |
+
|
|
|
79b470 |
+int virDomainNumaGetNodeCache(const virDomainNuma *numa,
|
|
|
79b470 |
+ size_t node,
|
|
|
79b470 |
+ size_t cache,
|
|
|
79b470 |
+ unsigned int *level,
|
|
|
79b470 |
+ unsigned int *size,
|
|
|
79b470 |
+ unsigned int *line,
|
|
|
79b470 |
+ virDomainCacheAssociativity *associativity,
|
|
|
79b470 |
+ virDomainCachePolicy *policy);
|
|
|
79b470 |
+
|
|
|
79b470 |
+ssize_t virDomainNumaGetNodeInitiator(const virDomainNuma *numa,
|
|
|
79b470 |
+ size_t node);
|
|
|
79b470 |
+
|
|
|
79b470 |
+size_t virDomainNumaGetInterconnectsCount(const virDomainNuma *numa);
|
|
|
79b470 |
+
|
|
|
79b470 |
+int virDomainNumaGetInterconnect(const virDomainNuma *numa,
|
|
|
79b470 |
+ size_t i,
|
|
|
79b470 |
+ virDomainNumaInterconnectType *type,
|
|
|
79b470 |
+ unsigned int *initiator,
|
|
|
79b470 |
+ unsigned int *target,
|
|
|
79b470 |
+ unsigned int *cache,
|
|
|
79b470 |
+ virDomainMemoryLatency *accessType,
|
|
|
79b470 |
+ unsigned long *value);
|
|
|
79b470 |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
79b470 |
index de95e3b116..fdd104cd25 100644
|
|
|
79b470 |
--- a/src/libvirt_private.syms
|
|
|
79b470 |
+++ b/src/libvirt_private.syms
|
|
|
79b470 |
@@ -820,14 +820,20 @@ virDomainNumaCheckABIStability;
|
|
|
79b470 |
virDomainNumaEquals;
|
|
|
79b470 |
virDomainNumaFree;
|
|
|
79b470 |
virDomainNumaGetCPUCountTotal;
|
|
|
79b470 |
+virDomainNumaGetInterconnect;
|
|
|
79b470 |
+virDomainNumaGetInterconnectsCount;
|
|
|
79b470 |
virDomainNumaGetMaxCPUID;
|
|
|
79b470 |
virDomainNumaGetMemorySize;
|
|
|
79b470 |
+virDomainNumaGetNodeCache;
|
|
|
79b470 |
+virDomainNumaGetNodeCacheCount;
|
|
|
79b470 |
virDomainNumaGetNodeCount;
|
|
|
79b470 |
virDomainNumaGetNodeCpumask;
|
|
|
79b470 |
virDomainNumaGetNodeDiscard;
|
|
|
79b470 |
virDomainNumaGetNodeDistance;
|
|
|
79b470 |
+virDomainNumaGetNodeInitiator;
|
|
|
79b470 |
virDomainNumaGetNodeMemoryAccessMode;
|
|
|
79b470 |
virDomainNumaGetNodeMemorySize;
|
|
|
79b470 |
+virDomainNumaHasHMAT;
|
|
|
79b470 |
virDomainNumaNew;
|
|
|
79b470 |
virDomainNumaNodeDistanceIsUsingDefaults;
|
|
|
79b470 |
virDomainNumaNodesDistancesAreBeingSet;
|
|
|
79b470 |
--
|
|
|
79b470 |
2.29.2
|
|
|
79b470 |
|