[PATCH 10/13] numa: expose HMAT APIs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



These APIs will be used by QEMU driver when building the command
line.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/numa_conf.c     | 139 +++++++++++++++++++++++++++++++++++++++
 src/conf/numa_conf.h     |  28 ++++++++
 src/libvirt_private.syms |   6 ++
 3 files changed, 173 insertions(+)

diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
index bf8442eada..b35e5040fc 100644
--- a/src/conf/numa_conf.c
+++ b/src/conf/numa_conf.c
@@ -1829,3 +1829,142 @@ virDomainNumaFillCPUsInNode(virDomainNumaPtr numa,
 
     return 0;
 }
+
+
+bool
+virDomainNumaHasHMAT(const virDomainNuma *numa)
+{
+    size_t i;
+
+    if (!numa)
+        return false;
+
+    if (numa->nlatencies)
+        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->nlatencies; i++) {
+        const virDomainNumaLatency *l = &numa->latencies[i];
+
+        if (l->target != node)
+            continue;
+
+        switch (l->type) {
+        case VIR_DOMAIN_NUMA_LATENCY_TYPE_LATENCY:
+            if (l->value < minLatency) {
+                minLatency = l->value;
+                candidateLatency = l->initiator;
+            }
+            break;
+
+        case VIR_DOMAIN_NUMA_LATENCY_TYPE_BANDWIDTH:
+            if (l->value > maxBandwidth) {
+                maxBandwidth = l->value;
+                candidateBandwidth = l->initiator;
+            }
+            break;
+        }
+    }
+
+    if (candidateLatency >= 0)
+        return candidateLatency;
+
+    return candidateBandwidth;
+}
+
+
+size_t
+virDomainNumaGetLatenciesCount(const virDomainNuma *numa)
+{
+    if (!numa)
+        return 0;
+
+    return numa->nlatencies;
+}
+
+
+int
+virDomainNumaGetLatency(const virDomainNuma *numa,
+                        size_t i,
+                        virDomainNumaLatencyType *type,
+                        unsigned int *initiator,
+                        unsigned int *target,
+                        unsigned int *cache,
+                        virDomainMemoryLatency *accessType,
+                        unsigned long *value)
+{
+    const virDomainNumaLatency *l;
+
+    if (!numa || i >= numa->nlatencies)
+        return -1;
+
+    l = &numa->latencies[i];
+    *type = l->type;
+    *initiator = l->initiator;
+    *target = l->target;
+    *cache = l->cache;
+    *accessType = l->accessType;
+    *value = l->value;
+    return 0;
+}
diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h
index 6d6e9de551..b150fe4037 100644
--- a/src/conf/numa_conf.h
+++ b/src/conf/numa_conf.h
@@ -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 virDomainNumaGetLatenciesCount(const virDomainNuma *numa);
+
+int virDomainNumaGetLatency(const virDomainNuma *numa,
+                            size_t i,
+                            virDomainNumaLatencyType *type,
+                            unsigned int *initiator,
+                            unsigned int *target,
+                            unsigned int *cache,
+                            virDomainMemoryLatency *accessType,
+                            unsigned long *value);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 65fe1c7f47..41e61e9b4d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -843,14 +843,20 @@ virDomainNumaEquals;
 virDomainNumaFillCPUsInNode;
 virDomainNumaFree;
 virDomainNumaGetCPUCountTotal;
+virDomainNumaGetLatenciesCount;
+virDomainNumaGetLatency;
 virDomainNumaGetMaxCPUID;
 virDomainNumaGetMemorySize;
+virDomainNumaGetNodeCache;
+virDomainNumaGetNodeCacheCount;
 virDomainNumaGetNodeCount;
 virDomainNumaGetNodeCpumask;
 virDomainNumaGetNodeDiscard;
 virDomainNumaGetNodeDistance;
+virDomainNumaGetNodeInitiator;
 virDomainNumaGetNodeMemoryAccessMode;
 virDomainNumaGetNodeMemorySize;
+virDomainNumaHasHMAT;
 virDomainNumaNew;
 virDomainNumaNodeDistanceIsUsingDefaults;
 virDomainNumaNodesDistancesAreBeingSet;
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux