Change in vdsm[master]: caps: Report online logical CPUs

vdelima at redhat.com vdelima at redhat.com
Wed Oct 8 11:37:09 UTC 2014


Vitor de Lima has uploaded a new change for review.

Change subject: caps: Report online logical CPUs
......................................................................

caps: Report online logical CPUs

Introduces a new information in the capabilities command which reports
the list of logical CPUs that are online during its execution.

This is necessary because the kernel allows logical CPUs to be disabled
and enable on-the-fly, and ppc64 hosts have only one enabled logical
CPU per core and several CPU threads disabled. So this patch is needed
in order to validate CPU pinning configurations and count the number of
logical CPUs properly.

Change-Id: Ia41df1758e629dc1087416c1dad3fa4d115243fb
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1148092
Signed-off-by: Vitor de Lima <vdelima at redhat.com>
---
M vdsm/caps.py
M vdsm/rpc/vdsmapi-schema.json
2 files changed, 17 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/89/33789/2

diff --git a/vdsm/caps.py b/vdsm/caps.py
index b8488b4..996dd76 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -207,6 +207,9 @@
     def sockets(self):
         return self._topology['sockets']
 
+    def onlineCpus(self):
+        return self._topology['onlineCpus']
+
 
 class KdumpStatus(object):
     UNKNOWN = -1
@@ -227,17 +230,21 @@
     caps = minidom.parseString(capabilities)
     host = caps.getElementsByTagName('host')[0]
     cells = host.getElementsByTagName('cells')[0]
-    cpus = cells.getElementsByTagName('cpu').length
 
     sockets = set()
     siblings = set()
+    onlineCpus = []
+
     for cpu in cells.getElementsByTagName('cpu'):
-        sockets.add(cpu.getAttribute('socket_id'))
-        siblings.add(cpu.getAttribute('siblings'))
+        if cpu.hasAttribute('socket_id') and cpu.hasAttribute('siblings'):
+            onlineCpus.append(cpu.getAttribute('id'))
+            sockets.add(cpu.getAttribute('socket_id'))
+            siblings.add(cpu.getAttribute('siblings'))
 
     topology = {'sockets': len(sockets),
                 'cores': len(siblings),
-                'threads': cpus}
+                'threads': len(onlineCpus),
+                'onlineCpus': onlineCpus}
 
     return topology
 
@@ -624,6 +631,7 @@
 
     caps['cpuThreads'] = str(cpuTopology.threads())
     caps['cpuSockets'] = str(cpuTopology.sockets())
+    caps['onlineCpus'] = ','.join(cpuTopology.onlineCpus())
     caps['cpuSpeed'] = cpuInfo.mhz()
     if config.getboolean('vars', 'fake_kvm_support'):
         if targetArch == Architecture.X86_64:
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index 6c25745..67780a7 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -1183,7 +1183,9 @@
 #
 # @cpuCores:            The number of CPU cores present
 #
-# @cpuSockets:          The numbet of CPU sockets
+# @cpuSockets:          The number of CPU sockets
+#
+# @onlineCpus:          The list of online logical CPUs
 #
 # @cpuSpeed:            The speed of each CPU (in MHz)
 #
@@ -1266,7 +1268,8 @@
 ##
 {'type': 'VdsmCapabilities',
  'data': {'kvmEnabled': 'bool', 'cpuThreads': 'uint', 'cpuCores': 'uint',
-          'cpuSockets': 'uint', 'cpuSpeed': 'float', 'cpuModel': 'str',
+          'cpuSockets': 'uint', 'onlineCpus': 'str',
+          'cpuSpeed': 'float', 'cpuModel': 'str',
           'cpuFlags': 'str', 'version_name': 'str', 'software_version': 'str',
           'software_revision': 'str', 'supportedENGINEs': ['str'],
           'supportedProtocols': ['str'], 'clusterLevels': ['str'],


-- 
To view, visit http://gerrit.ovirt.org/33789
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia41df1758e629dc1087416c1dad3fa4d115243fb
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Vitor de Lima <vdelima at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Vitor de Lima <vdelima at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server


More information about the vdsm-patches mailing list