Change in vdsm[master]: numa: only use libvirt for memory info

mpolednik at redhat.com mpolednik at redhat.com
Thu Feb 4 14:45:11 UTC 2016


Martin Polednik has uploaded a new change for review.

Change subject: numa: only use libvirt for memory info
......................................................................

numa: only use libvirt for memory info

Current code queries memory usage via libvirt or /proc/meminfo,
depending on the state of machine's numa support. For some time,
(guaranteed 7.0+) even machines without direct numa support do
expose a single node that we can query.

This patch removes the 'UMA' (unified memory architecture) code branch
and uses libvirt for all numa memory queries.

Change-Id: I0b5594a71047aae53374e4af5da95e3cd56f3835
Signed-off-by: Martin Polednik <mpolednik at redhat.com>
---
M tests/capsTests.py
M tests/samplingTests.py
M vdsm/caps.py
M vdsm/virt/sampling.py
4 files changed, 4 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/91/53091/1

diff --git a/tests/capsTests.py b/tests/capsTests.py
index 8f64332..d996ab2 100644
--- a/tests/capsTests.py
+++ b/tests/capsTests.py
@@ -131,13 +131,6 @@
                   'totalMemory': '49141'}}
         self.assertEqual(t, expectedNumaInfo)
 
-    @MonkeyPatch(utils, 'readMemInfo', lambda: {
-        'MemTotal': 50321208, 'MemFree': 47906488})
-    def testGetUMAMemStats(self):
-        t = caps.getUMAHostMemoryStats()
-        expectedInfo = {'total': '49141', 'free': '46783'}
-        self.assertEqual(t, expectedInfo)
-
     @MonkeyPatch(commands, 'execCmd', lambda x: _getCapsNumaDistanceTestData(
         "caps_numactl_4_nodes.out"))
     def testNumaNodeDistance(self):
diff --git a/tests/samplingTests.py b/tests/samplingTests.py
index 99bc06a..62a3fc3 100644
--- a/tests/samplingTests.py
+++ b/tests/samplingTests.py
@@ -189,7 +189,7 @@
     def _monkeyPatchedMemorySample(self, freeMemory, totalMemory):
         node_id, cpu_id = 0, 0
 
-        def fakeMemoryStats():
+        def fakeMemoryStats(_):
             return {
                 'free': freeMemory,
                 'total': totalMemory
@@ -204,7 +204,7 @@
 
         return MonkeyPatchScope([(caps, 'getNumaTopology',
                                   fakeNumaTopology),
-                                 (caps, 'getUMAHostMemoryStats',
+                                 (caps, 'getMemoryStatsByNumaCell',
                                   fakeMemoryStats)])
 
     def testMemoryStatsWithZeroMemoryAsString(self):
diff --git a/vdsm/caps.py b/vdsm/caps.py
index ae7d86f..4694368 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -229,10 +229,7 @@
             cpus.append(int(cpu.get('id')))
         cellInfo['cpus'] = cpus
         cellIndex = cell.get('id')
-        if len(cellSets) < 2:
-            memInfo = getUMAHostMemoryStats()
-        else:
-            memInfo = getMemoryStatsByNumaCell(int(cellIndex))
+        memInfo = getMemoryStatsByNumaCell(int(cellIndex))
         cellInfo['totalMemory'] = memInfo['total']
         cellsInfo[cellIndex] = cellInfo
     return cellsInfo
@@ -250,19 +247,6 @@
     cellMemInfo['total'] = str(cellMemInfo['total'] / 1024)
     cellMemInfo['free'] = str(cellMemInfo['free'] / 1024)
     return cellMemInfo
-
-
-def getUMAHostMemoryStats():
-    """
-    Get the memory stats of a UMA host, the unit is MiB.
-
-    :return: dict like {'total': '49141', 'free': '46783'}
-    """
-    memDict = {}
-    memInfo = utils.readMemInfo()
-    memDict['total'] = str(memInfo['MemTotal'] / 1024)
-    memDict['free'] = str(memInfo['MemFree'] / 1024)
-    return memDict
 
 
 @utils.memoized
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index a4c5ba7..91b10a0 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -168,10 +168,7 @@
         numaTopology = caps.getNumaTopology()
         for nodeIndex in numaTopology:
             nodeMemSample = {}
-            if len(numaTopology) < 2:
-                memInfo = caps.getUMAHostMemoryStats()
-            else:
-                memInfo = caps.getMemoryStatsByNumaCell(int(nodeIndex))
+            memInfo = caps.getMemoryStatsByNumaCell(int(nodeIndex))
             nodeMemSample['memFree'] = memInfo['free']
             # in case the numa node has zero memory assigned, report the whole
             # memory as used


-- 
To view, visit https://gerrit.ovirt.org/53091
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b5594a71047aae53374e4af5da95e3cd56f3835
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik at redhat.com>


More information about the vdsm-patches mailing list