Change in vdsm[master]: numa: get distance information from libvirt

mpolednik at redhat.com mpolednik at redhat.com
Tue Feb 9 12:38:07 UTC 2016


Martin Polednik has uploaded a new change for review.

Change subject: numa: get distance information from libvirt
......................................................................

numa: get distance information from libvirt

It is not necessary to use numactl to access numa cell distances as
libvirt already provides us with that exact information. Although this
patch does separate pass over libvirt capabilities, it opens up
possibility for single pass in future of the series.

Change-Id: I80b423e27fa37bc49388cca72785b081e4365e69
Bug-Url: https://bugzilla.redhat.com/??????
Signed-off-by: Martin Polednik <mpolednik at redhat.com>
---
M debian/vdsm-tests.install
M tests/Makefile.am
M tests/capsTests.py
A tests/caps_libvirt_ibm_S822L_le.out
M vdsm.spec.in
M vdsm/caps.py
6 files changed, 175 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/85/53285/1

diff --git a/debian/vdsm-tests.install b/debian/vdsm-tests.install
index 96518d4..eed1b52 100644
--- a/debian/vdsm-tests.install
+++ b/debian/vdsm-tests.install
@@ -2,6 +2,7 @@
 usr/share/vdsm/tests/*.py
 usr/share/vdsm/tests/caps_libvirt_amd_6274.out
 usr/share/vdsm/tests/caps_libvirt_ibm_S822L.out
+usr/share/vdsm/tests/caps_libvirt_ibm_S822L_le.out
 usr/share/vdsm/tests/caps_libvirt_intel_E31220.out
 usr/share/vdsm/tests/caps_libvirt_intel_E5606.out
 usr/share/vdsm/tests/caps_libvirt_intel_E5649.out
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 87abb5d..498ffee 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -179,6 +179,7 @@
 	caps_libvirt_intel_E5649.out \
 	caps_libvirt_amd_6274.out \
 	caps_libvirt_ibm_S822L.out \
+	caps_libvirt_ibm_S822L_le.out \
 	caps_libvirt_intel_E31220.out \
 	caps_libvirt_intel_E5606.out \
 	caps_libvirt_intel_i73770.out \
diff --git a/tests/capsTests.py b/tests/capsTests.py
index 3d807a2..a701f24 100644
--- a/tests/capsTests.py
+++ b/tests/capsTests.py
@@ -131,15 +131,14 @@
                   'totalMemory': '49141'}}
         self.assertEqual(t, expectedNumaInfo)
 
-    @MonkeyPatch(commands, 'execCmd', lambda x: _getCapsNumaDistanceTestData(
-        "caps_numactl_4_nodes.out"))
+    @MonkeyPatch(caps, '_getCapsXMLStr', lambda: _getTestData(
+        'caps_libvirt_ibm_S822L_le.out'))
     def testNumaNodeDistance(self):
         t = caps.getNumaNodeDistance()
-        expectedDistanceInfo = {
-            '0': [10, 20, 20, 20],
-            '1': [20, 10, 20, 20],
-            '2': [20, 20, 10, 20],
-            '3': [20, 20, 20, 10]}
+        expectedDistanceInfo = {'0': ['10', '20', '40', '40'],
+                                '1': ['20', '10', '40', '40'],
+                                '16': ['40', '40', '10', '20'],
+                                '17': ['40', '40', '20', '10']}
         self.assertEqual(t, expectedDistanceInfo)
 
     @MonkeyPatch(commands, 'execCmd', lambda x: (0, ['0'], []))
diff --git a/tests/caps_libvirt_ibm_S822L_le.out b/tests/caps_libvirt_ibm_S822L_le.out
new file mode 100644
index 0000000..bc8b90c
--- /dev/null
+++ b/tests/caps_libvirt_ibm_S822L_le.out
@@ -0,0 +1,153 @@
+<capabilities>
+
+  <host>
+    <uuid>bfd7abcb-141c-40f1-91a4-0a341b59648a</uuid>
+    <cpu>
+      <arch>ppc64le</arch>
+      <model>POWER8</model>
+      <vendor>IBM</vendor>
+      <topology sockets='1' cores='5' threads='8'/>
+      <pages unit='KiB' size='64'/>
+      <pages unit='KiB' size='16384'/>
+    </cpu>
+    <power_management>
+      <suspend_mem/>
+    </power_management>
+    <migration_features>
+      <live/>
+      <uri_transports>
+        <uri_transport>tcp</uri_transport>
+        <uri_transport>rdma</uri_transport>
+      </uri_transports>
+    </migration_features>
+    <topology>
+      <cells num='4'>
+        <cell id='0'>
+          <memory unit='KiB'>67108864</memory>
+          <pages unit='KiB' size='64'>1048576</pages>
+          <pages unit='KiB' size='16384'>0</pages>
+          <distances>
+            <sibling id='0' value='10'/>
+            <sibling id='1' value='20'/>
+            <sibling id='16' value='40'/>
+            <sibling id='17' value='40'/>
+          </distances>
+          <cpus num='5'>
+            <cpu id='0' socket_id='0' core_id='32' siblings='0'/>
+            <cpu id='8' socket_id='0' core_id='40' siblings='8'/>
+            <cpu id='16' socket_id='0' core_id='96' siblings='16'/>
+            <cpu id='24' socket_id='0' core_id='104' siblings='24'/>
+            <cpu id='32' socket_id='0' core_id='112' siblings='32'/>
+          </cpus>
+        </cell>
+        <cell id='1'>
+          <memory unit='KiB'>67108864</memory>
+          <pages unit='KiB' size='64'>1048576</pages>
+          <pages unit='KiB' size='16384'>0</pages>
+          <distances>
+            <sibling id='0' value='20'/>
+            <sibling id='1' value='10'/>
+            <sibling id='16' value='40'/>
+            <sibling id='17' value='40'/>
+          </distances>
+          <cpus num='5'>
+            <cpu id='40' socket_id='1' core_id='160' siblings='40'/>
+            <cpu id='48' socket_id='1' core_id='168' siblings='48'/>
+            <cpu id='56' socket_id='1' core_id='176' siblings='56'/>
+            <cpu id='64' socket_id='1' core_id='224' siblings='64'/>
+            <cpu id='72' socket_id='1' core_id='232' siblings='72'/>
+          </cpus>
+        </cell>
+        <cell id='16'>
+          <memory unit='KiB'>67108864</memory>
+          <pages unit='KiB' size='64'>1048576</pages>
+          <pages unit='KiB' size='16384'>0</pages>
+          <distances>
+            <sibling id='0' value='40'/>
+            <sibling id='1' value='40'/>
+            <sibling id='16' value='10'/>
+            <sibling id='17' value='20'/>
+          </distances>
+          <cpus num='5'>
+            <cpu id='80' socket_id='16' core_id='2080' siblings='80'/>
+            <cpu id='88' socket_id='16' core_id='2088' siblings='88'/>
+            <cpu id='96' socket_id='16' core_id='2096' siblings='96'/>
+            <cpu id='104' socket_id='16' core_id='2152' siblings='104'/>
+            <cpu id='112' socket_id='16' core_id='2160' siblings='112'/>
+          </cpus>
+        </cell>
+        <cell id='17'>
+          <memory unit='KiB'>67108864</memory>
+          <pages unit='KiB' size='64'>1048576</pages>
+          <pages unit='KiB' size='16384'>0</pages>
+          <distances>
+            <sibling id='0' value='40'/>
+            <sibling id='1' value='40'/>
+            <sibling id='16' value='20'/>
+            <sibling id='17' value='10'/>
+          </distances>
+          <cpus num='5'>
+            <cpu id='120' socket_id='17' core_id='2208' siblings='120'/>
+            <cpu id='128' socket_id='17' core_id='2224' siblings='128'/>
+            <cpu id='136' socket_id='17' core_id='2272' siblings='136'/>
+            <cpu id='144' socket_id='17' core_id='2280' siblings='144'/>
+            <cpu id='152' socket_id='17' core_id='2288' siblings='152'/>
+          </cpus>
+        </cell>
+      </cells>
+    </topology>
+    <secmodel>
+      <model>selinux</model>
+      <doi>0</doi>
+      <baselabel type='kvm'>system_u:system_r:svirt_t:s0</baselabel>
+      <baselabel type='qemu'>system_u:system_r:svirt_tcg_t:s0</baselabel>
+    </secmodel>
+    <secmodel>
+      <model>dac</model>
+      <doi>0</doi>
+      <baselabel type='kvm'>+107:+107</baselabel>
+      <baselabel type='qemu'>+107:+107</baselabel>
+    </secmodel>
+  </host>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='ppc64'>
+      <wordsize>64</wordsize>
+      <emulator>/usr/libexec/qemu-kvm</emulator>
+      <machine maxCpus='255'>pseries-rhel7.2.0</machine>
+      <machine canonical='pseries-rhel7.2.0' maxCpus='255'>pseries</machine>
+      <domain type='qemu'/>
+      <domain type='kvm'>
+        <emulator>/usr/libexec/qemu-kvm</emulator>
+      </domain>
+    </arch>
+    <features>
+      <cpuselection/>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+  <guest>
+    <os_type>hvm</os_type>
+    <arch name='ppc64le'>
+      <wordsize>64</wordsize>
+      <emulator>/usr/libexec/qemu-kvm</emulator>
+      <machine maxCpus='255'>pseries-rhel7.2.0</machine>
+      <machine canonical='pseries-rhel7.2.0' maxCpus='255'>pseries</machine>
+      <domain type='qemu'/>
+      <domain type='kvm'>
+        <emulator>/usr/libexec/qemu-kvm</emulator>
+      </domain>
+    </arch>
+    <features>
+      <cpuselection/>
+      <deviceboot/>
+      <disksnapshot default='on' toggle='no'/>
+    </features>
+  </guest>
+
+</capabilities>
+
+
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 21f0fd3..725e28e 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1202,6 +1202,7 @@
 %{_datadir}/%{vdsm_name}/tests/caps_libvirt_intel_E5649.out
 %{_datadir}/%{vdsm_name}/tests/caps_libvirt_amd_6274.out
 %{_datadir}/%{vdsm_name}/tests/caps_libvirt_ibm_S822L.out
+%{_datadir}/%{vdsm_name}/tests/caps_libvirt_ibm_S822L_le.out
 %{_datadir}/%{vdsm_name}/tests/caps_libvirt_intel_E31220.out
 %{_datadir}/%{vdsm_name}/tests/caps_libvirt_intel_E5606.out
 %{_datadir}/%{vdsm_name}/tests/caps_libvirt_intel_i73770.out
diff --git a/vdsm/caps.py b/vdsm/caps.py
index 3c27943..e6cc817 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -27,7 +27,6 @@
 import time
 import linecache
 import glob
-import re
 import xml.etree.ElementTree as ET
 from distutils.version import LooseVersion
 
@@ -250,19 +249,19 @@
 
 
 @utils.memoized
-def getNumaNodeDistance():
-    nodeDistance = {}
-    retcode, out, err = commands.execCmd(['numactl', '--hardware'])
-    if retcode != 0:
-        logging.error("Get error when execute numactl", exc_info=True)
-        return nodeDistance
-    pattern = re.compile(r'\s+(\d+):(.*)')
-    for item in out:
-        match = pattern.match(item)
-        if match:
-            nodeDistance[match.group(1)] = map(int,
-                                               match.group(2).strip().split())
-    return nodeDistance
+def getNumaNodeDistance(capabilities=None):
+    if capabilities is None:
+        capabilities = _getCapsXMLStr()
+    caps = ET.fromstring(capabilities)
+    cells = caps.find('host').find('.//cells').findall('cell')
+    distances = {}
+    for cell in cells:
+        cellIndex = cell.get('id')
+        distances[cellIndex] = []
+        for sibling in cell.find('distances').findall('sibling'):
+            distances[cellIndex].append(sibling.get('value'))
+
+    return distances
 
 
 @utils.memoized


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I80b423e27fa37bc49388cca72785b081e4365e69
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