Roy Golan has uploaded a new change for review. Change subject: refine calculation of cpu topology ......................................................................
refine calculation of cpu topology engine sends along with createInfo the following: smp // VM.numOfCpus smpCoresPerSocket // VM.cpuPerSocket validated against ConfigValue.MaxNumOfSockets currently = 16 maxVCpus // ConfigValue.MaxNumberOfVmCpus smpThreadsPerCore // optional - we don't send so defaults to 1 we need to send also * MaxNumOfSockets the xml should be calculated like this <vcpu current="smp">M</vcpu> <topology cores="C" sockets="S" threads="T"/> smp = smp C = smpCoresPerSocket T = cpuThreads S = maxNumberOfSockets M = min(maxVCpus, (C * S * T)) Change-Id: I0d71dfe98b67440c084b2a7bf8b292f6b9c3ae19 Bug-Url: https://bugzilla.redhat.com/1121295 Signed-off-by: Roy Golan <[email protected]> --- M tests/vmTests.py M tests/vmTestsData.py M vdsm/rpc/vdsmapi-schema.json M vdsm/virt/vm.py 4 files changed, 39 insertions(+), 26 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/32/31032/1 diff --git a/tests/vmTests.py b/tests/vmTests.py index 7ee2eb8..53a41c9 100644 --- a/tests/vmTests.py +++ b/tests/vmTests.py @@ -165,7 +165,7 @@ <uuid>9ffe28b6-6134-4b1e-8804-1185f49c436f</uuid> <memory>1048576</memory> <currentMemory>1048576</currentMemory> - <vcpu current="8">160</vcpu> + <vcpu current="8">16</vcpu> <memtune> <min_guarantee>524288</min_guarantee> </memtune> @@ -400,7 +400,7 @@ <feature name="sse4.1" policy="require"/> <feature name="sse4.2" policy="require"/> <feature name="svm" policy="disable"/> - <topology cores="2" sockets="40" threads="2"/> + <topology cores="2" sockets="16" threads="2"/> <numa> <cell cpus="0-1" memory="5242880"/> <cell cpus="2,3" memory="5242880"/> diff --git a/tests/vmTestsData.py b/tests/vmTestsData.py index 3cee160..baac543 100644 --- a/tests/vmTestsData.py +++ b/tests/vmTestsData.py @@ -20,13 +20,14 @@ CONF_TO_DOMXML_X86_64 = [({ 'vmId': '9ffe28b6-6134-4b1e-8804-1185f49c436f', - 'smp': '8', 'memSize': '1024', 'memGuaranteedSize': '512', + 'memSize': '1024', 'memGuaranteedSize': '512', 'displayPort': '-1', 'vmName': 'testVm', 'display': 'vnc', 'emulatedMachine': 'pc', 'boot': '', 'timeOffset': 0, 'acpiEnable': 'true', 'cpuType': 'qemu64', 'smpCoresPerSocket': 1, 'smpThreadsPerCore': 1, - 'smp': '1', 'cpuPinning': {}, 'numaTune': {}, 'maxVCpus': '160', + 'smp': '8', 'maxNumberOfSockets': '16', + 'cpuPinning': {}, 'numaTune': {}, 'maxVCpus': '160', 'vmchannel': 'true', 'qgaEnable': 'true', 'tabletEnable': False, 'displayNetwork': 'mydisp', 'custom': {}, @@ -38,7 +39,7 @@ <uuid>%(vmId)s</uuid> <memory>1048576</memory> <currentMemory>1048576</currentMemory> - <vcpu current="1">160</vcpu> + <vcpu current="8">16</vcpu> <memtune> <min_guarantee>524288</min_guarantee> </memtune> @@ -80,7 +81,7 @@ <cpu match="exact"> <model>qemu64</model> <feature name="svm" policy="disable"/> - <topology cores="1" sockets="160" threads="1"/> + <topology cores="1" sockets="16" threads="1"/> <numa/> </cpu> </domain> @@ -88,13 +89,14 @@ CONF_TO_DOMXML_PPC64 = [({ 'vmId': '9ffe28b6-6134-4b1e-8804-1185f49c436f', - 'smp': '8', 'memSize': '1024', 'memGuaranteedSize': '512', + 'memSize': '1024', 'memGuaranteedSize': '512', 'displayPort': '-1', 'vmName': 'testVm', 'display': 'vnc', 'emulatedMachine': 'pc', 'boot': '', 'timeOffset': 0, 'acpiEnable': 'true', 'cpuType': 'qemu64', 'smpCoresPerSocket': 1, 'smpThreadsPerCore': 1, - 'smp': '1', 'cpuPinning': {}, 'numaTune': {}, 'maxVCpus': '160', + 'smp': '8', 'maxNumberOfSockets': '16', + 'cpuPinning': {}, 'numaTune': {}, 'maxVCpus': '160', 'vmchannel': 'true', 'qgaEnable': 'true', 'tabletEnable': False, 'displayNetwork': 'mydisp', 'custom': {}, @@ -107,7 +109,7 @@ <uuid>%(vmId)s</uuid> <memory>1048576</memory> <currentMemory>1048576</currentMemory> - <vcpu current="1">160</vcpu> + <vcpu current="8">16</vcpu> <memtune> <min_guarantee>524288</min_guarantee> </memtune> @@ -134,7 +136,7 @@ </clock> <cputune/> <cpu> - <topology cores="1" sockets="160" threads="1"/> + <topology cores="1" sockets="16" threads="1"/> <numa/> </cpu> <qemu:commandline> diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json index c301912..d0d58a3 100644 --- a/vdsm/rpc/vdsmapi-schema.json +++ b/vdsm/rpc/vdsmapi-schema.json @@ -3329,6 +3329,8 @@ # # @smpThreadsPerCore: #optional Indicates the number of CPU threads per core # +# @maxNumberOfSockets: #optional Indicates the max number of sockets +# # @timeOffset: The time difference from host to the VM in seconds # # @transparentHugePages: Indicates if the Transparent Huge Pages feature is @@ -3346,7 +3348,7 @@ # # @guestNumaNodes: #optional Indicates the guest numa topology. # -# Since: 4.10.0 +# Since: 4.16.2 ## {'type': 'VmParameters', 'data': {'acpiEnable': 'bool', '*bootMenuEnable': 'bool', @@ -3354,8 +3356,9 @@ 'display': 'VmDisplayType', '*hypervEnable': 'bool', 'kvmEnable': 'bool', 'memSize': 'uint', 'nice': 'int', 'smp': 'uint', '*smpCoresPerSocket': 'uint', - '*smpThreadsPerCore': 'uint', 'timeOffset': 'uint', - 'transparentHugePages': 'bool', 'vmId': 'UUID', 'vmName': 'str', + '*smpThreadsPerCore': 'uint', '*maxNumberOfSockets': 'int', + 'timeOffset': 'uint', 'transparentHugePages': 'bool', + 'vmId': 'UUID', 'vmName': 'str', 'vmType': 'VmType', '*launchPaused': 'bool', 'numaTune': 'NumaTune', 'guestNumaNodes': ['GuestNumaNode']}} diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index 30a5679..1390d6f 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -684,7 +684,7 @@ """ self.conf = conf self.log = log - + self._topology = self._calcTopology() self.arch = arch self.doc = xml.dom.minidom.Document() @@ -712,8 +712,9 @@ memSizeKB = str(int(self.conf.get('memSize', '256')) * 1024) self.dom.appendChildWithArgs('memory', text=memSizeKB) self.dom.appendChildWithArgs('currentMemory', text=memSizeKB) - vcpu = self.dom.appendChildWithArgs('vcpu', text=self._getMaxVCpus()) - vcpu.setAttrs(**{'current': self._getSmp()}) + vcpu = self.dom.appendChildWithArgs( + 'vcpu', text=str(self._topology['maxVCpus'])) + vcpu.setAttrs(**{'current': str(self._topology['smp'])}) memSizeGuaranteedKB = str(1024 * int( self.conf.get('memGuaranteedSize', '0') @@ -906,12 +907,10 @@ if ('smpCoresPerSocket' in self.conf or 'smpThreadsPerCore' in self.conf): - maxVCpus = int(self._getMaxVCpus()) - cores = int(self.conf.get('smpCoresPerSocket', '1')) - threads = int(self.conf.get('smpThreadsPerCore', '1')) cpu.appendChildWithArgs('topology', - sockets=str(maxVCpus / cores / threads), - cores=str(cores), threads=str(threads)) + cores=str(self._topology['cores']), + sockets=str(self._topology['sockets']), + threads=str(self._topology['threads'])) # CPU-pinning support # see http://www.ovirt.org/wiki/Features/Design/cpu-pinning @@ -1011,12 +1010,21 @@ def toxml(self): return self.doc.toprettyxml(encoding='utf-8') - def _getSmp(self): - return self.conf.get('smp', '1') + def _calcTopology(self): + smp = int(self.conf.get('smp', '1')) + cores = int(self.conf.get('smpCoresPerSocket', '1')) + threads = int(self.conf.get('smpThreadsPerCore', '1')) + sockets = int(self.conf.get('maxNumberOfSockets', '16')) + maxVCpus = int(self.conf.get('maxVCpus', str(smp))) + maxVCpus = min(maxVCpus, (cores * sockets * threads)) - def _getMaxVCpus(self): - return self.conf.get('maxVCpus', self._getSmp()) - + return { + 'smp': smp, + 'cores': cores, + 'threads': threads, + 'sockets': sockets, + 'maxVCpus': maxVCpus + } class VmDevice(object): __slots__ = ('deviceType', 'device', 'alias', 'specParams', 'deviceId', -- To view, visit http://gerrit.ovirt.org/31032 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0d71dfe98b67440c084b2a7bf8b292f6b9c3ae19 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: ovirt-3.5 Gerrit-Owner: Roy Golan <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
