]> xenbits.xensource.com Git - libvirt.git/commitdiff
numa: expose HMAT APIs
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 29 May 2020 12:55:57 +0000 (14:55 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 8 Jul 2020 10:05:24 +0000 (12:05 +0200)
These APIs will be used by QEMU driver when building the command
line.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/conf/numa_conf.c
src/conf/numa_conf.h
src/libvirt_private.syms

index 604056e3581bb98020ec28decb1c200ae9905cb0..28e831be11864b878166ec1f27c1cd299bf91d98 100644 (file)
@@ -1829,3 +1829,142 @@ virDomainNumaFillCPUsInNode(virDomainNumaPtr numa,
 
     return 0;
 }
+
+
+bool
+virDomainNumaHasHMAT(const virDomainNuma *numa)
+{
+    size_t i;
+
+    if (!numa)
+        return false;
+
+    if (numa->ninterconnects)
+        return true;
+
+    for (i = 0; i < numa->nmem_nodes; i++) {
+        if (numa->mem_nodes[i].ncaches)
+            return true;
+    }
+
+    return false;
+}
+
+
+size_t
+virDomainNumaGetNodeCacheCount(const virDomainNuma *numa,
+                               size_t node)
+{
+    if (!numa || node >= numa->nmem_nodes)
+        return 0;
+
+    return numa->mem_nodes[node].ncaches;
+}
+
+
+int
+virDomainNumaGetNodeCache(const virDomainNuma *numa,
+                          size_t node,
+                          size_t cache,
+                          unsigned int *level,
+                          unsigned int *size,
+                          unsigned int *line,
+                          virDomainCacheAssociativity *associativity,
+                          virDomainCachePolicy *policy)
+{
+    const virDomainNumaNode *cell;
+
+    if (!numa || node >= numa->nmem_nodes)
+        return -1;
+
+    cell = &numa->mem_nodes[node];
+
+    if (cache >= cell->ncaches)
+        return -1;
+
+    *level = cell->caches[cache].level;
+    *size = cell->caches[cache].size;
+    *line = cell->caches[cache].line;
+    *associativity = cell->caches[cache].associativity;
+    *policy = cell->caches[cache].policy;
+    return 0;
+}
+
+
+ssize_t
+virDomainNumaGetNodeInitiator(const virDomainNuma *numa,
+                              size_t node)
+{
+    size_t i;
+    unsigned int maxBandwidth = 0;
+    ssize_t candidateBandwidth = -1;
+    unsigned int minLatency = UINT_MAX;
+    ssize_t candidateLatency = -1;
+
+    if (!numa || node >= numa->nmem_nodes)
+        return -1;
+
+    for (i = 0; i < numa->ninterconnects; i++) {
+        const virDomainNumaInterconnect *l = &numa->interconnects[i];
+
+        if (l->target != node)
+            continue;
+
+        switch (l->type) {
+        case VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_LATENCY:
+            if (l->value < minLatency) {
+                minLatency = l->value;
+                candidateLatency = l->initiator;
+            }
+            break;
+
+        case VIR_DOMAIN_NUMA_INTERCONNECT_TYPE_BANDWIDTH:
+            if (l->value > maxBandwidth) {
+                maxBandwidth = l->value;
+                candidateBandwidth = l->initiator;
+            }
+            break;
+        }
+    }
+
+    if (candidateLatency >= 0)
+        return candidateLatency;
+
+    return candidateBandwidth;
+}
+
+
+size_t
+virDomainNumaGetInterconnectsCount(const virDomainNuma *numa)
+{
+    if (!numa)
+        return 0;
+
+    return numa->ninterconnects;
+}
+
+
+int
+virDomainNumaGetInterconnect(const virDomainNuma *numa,
+                             size_t i,
+                             virDomainNumaInterconnectType *type,
+                             unsigned int *initiator,
+                             unsigned int *target,
+                             unsigned int *cache,
+                             virDomainMemoryLatency *accessType,
+                             unsigned long *value)
+{
+    const virDomainNumaInterconnect *l;
+
+    if (!numa || i >= numa->ninterconnects)
+        return -1;
+
+    l = &numa->interconnects[i];
+    *type = l->type;
+    *initiator = l->initiator;
+    *target = l->target;
+    *cache = l->cache;
+    *accessType = l->accessType;
+    *value = l->value;
+    return 0;
+}
index 8ddf293cc380d0021759bbd60ba2ae01d9d0218b..db5d79e62a66d96d459d99c82db010b7ecf8ea3a 100644 (file)
@@ -222,3 +222,31 @@ unsigned int virDomainNumaGetCPUCountTotal(virDomainNumaPtr numa);
 
 int virDomainNumaFillCPUsInNode(virDomainNumaPtr numa, size_t node,
                                 unsigned int maxCpus);
+
+bool virDomainNumaHasHMAT(const virDomainNuma *numa);
+
+size_t virDomainNumaGetNodeCacheCount(const virDomainNuma *numa,
+                                       size_t node);
+
+int virDomainNumaGetNodeCache(const virDomainNuma *numa,
+                              size_t node,
+                              size_t cache,
+                              unsigned int *level,
+                              unsigned int *size,
+                              unsigned int *line,
+                              virDomainCacheAssociativity *associativity,
+                              virDomainCachePolicy *policy);
+
+ssize_t virDomainNumaGetNodeInitiator(const virDomainNuma *numa,
+                                      size_t node);
+
+size_t virDomainNumaGetInterconnectsCount(const virDomainNuma *numa);
+
+int virDomainNumaGetInterconnect(const virDomainNuma *numa,
+                                 size_t i,
+                                 virDomainNumaInterconnectType *type,
+                                 unsigned int *initiator,
+                                 unsigned int *target,
+                                 unsigned int *cache,
+                                 virDomainMemoryLatency *accessType,
+                                 unsigned long *value);
index 7a64b92f3544d541b2693ee304e407830f2000a3..d6b87b72f4bd09fae163b58302d2d9e0104acb94 100644 (file)
@@ -843,14 +843,20 @@ virDomainNumaEquals;
 virDomainNumaFillCPUsInNode;
 virDomainNumaFree;
 virDomainNumaGetCPUCountTotal;
+virDomainNumaGetInterconnect;
+virDomainNumaGetInterconnectsCount;
 virDomainNumaGetMaxCPUID;
 virDomainNumaGetMemorySize;
+virDomainNumaGetNodeCache;
+virDomainNumaGetNodeCacheCount;
 virDomainNumaGetNodeCount;
 virDomainNumaGetNodeCpumask;
 virDomainNumaGetNodeDiscard;
 virDomainNumaGetNodeDistance;
+virDomainNumaGetNodeInitiator;
 virDomainNumaGetNodeMemoryAccessMode;
 virDomainNumaGetNodeMemorySize;
+virDomainNumaHasHMAT;
 virDomainNumaNew;
 virDomainNumaNodeDistanceIsUsingDefaults;
 virDomainNumaNodesDistancesAreBeingSet;