summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-08-03 22:32:46 +0000
committerGerrit Code Review <review@openstack.org>2016-08-03 22:32:46 +0000
commitb5d9af919d595bc80cdd2d2cf1ed3dbadd6fcc10 (patch)
tree4593fe4f375e9b32ea0034cd8161c1cdc31549cc
parentb73590c45560da37ee02289e9e33c989835d57a3 (diff)
parent57638a8c83f98a8c139378b3b1e920b4f1c49a95 (diff)
downloadnova-b5d9af919d595bc80cdd2d2cf1ed3dbadd6fcc10.tar.gz
Merge "virt/hardware: Fix 'isolate' case on non-SMT hosts" into stable/mitaka
-rw-r--r--nova/tests/unit/virt/test_hardware.py19
-rw-r--r--nova/virt/hardware.py3
2 files changed, 19 insertions, 3 deletions
diff --git a/nova/tests/unit/virt/test_hardware.py b/nova/tests/unit/virt/test_hardware.py
index fef3dd0141..4ac5833b10 100644
--- a/nova/tests/unit/virt/test_hardware.py
+++ b/nova/tests/unit/virt/test_hardware.py
@@ -2031,7 +2031,7 @@ class CPUPinningCellTestCase(test.NoDBTestCase, _CPUPinningTestCaseBase):
inst_pin = hw._numa_fit_instance_cell_with_pinning(host_pin, inst_pin)
self.assertInstanceCellPinned(inst_pin)
- got_topo = objects.VirtCPUTopology(sockets=1, cores=1, threads=3)
+ got_topo = objects.VirtCPUTopology(sockets=1, cores=3, threads=1)
self.assertEqualTopology(got_topo, inst_pin.cpu_topology)
got_pinning = {x: x for x in range(0, 3)}
self.assertEqual(got_pinning, inst_pin.cpu_pinning)
@@ -2057,7 +2057,7 @@ class CPUPinningCellTestCase(test.NoDBTestCase, _CPUPinningTestCaseBase):
inst_pin = hw._numa_fit_instance_cell_with_pinning(host_pin, inst_pin)
self.assertInstanceCellPinned(inst_pin)
- got_topo = objects.VirtCPUTopology(sockets=1, cores=1, threads=4)
+ got_topo = objects.VirtCPUTopology(sockets=1, cores=4, threads=1)
self.assertEqualTopology(got_topo, inst_pin.cpu_topology)
got_pinning = {x: x for x in range(0, 4)}
self.assertEqual(got_pinning, inst_pin.cpu_pinning)
@@ -2289,6 +2289,21 @@ class CPUPinningCellTestCase(test.NoDBTestCase, _CPUPinningTestCaseBase):
def test_get_pinning_isolate_policy_fits(self):
host_pin = objects.NUMACell(id=0, cpuset=set([0, 1, 2, 3]),
memory=4096, memory_usage=0,
+ siblings=[],
+ mempages=[], pinned_cpus=set([]))
+ inst_pin = objects.InstanceNUMACell(
+ cpuset=set([0, 1]),
+ memory=2048,
+ cpu_policy=fields.CPUAllocationPolicy.DEDICATED,
+ cpu_thread_policy=fields.CPUThreadAllocationPolicy.ISOLATE)
+ inst_pin = hw._numa_fit_instance_cell_with_pinning(host_pin, inst_pin)
+ self.assertInstanceCellPinned(inst_pin)
+ got_topo = objects.VirtCPUTopology(sockets=1, cores=2, threads=1)
+ self.assertEqualTopology(got_topo, inst_pin.cpu_topology)
+
+ def test_get_pinning_isolate_policy_fits_ht_host(self):
+ host_pin = objects.NUMACell(id=0, cpuset=set([0, 1, 2, 3]),
+ memory=4096, memory_usage=0,
siblings=[set([0, 1]), set([2, 3])],
mempages=[], pinned_cpus=set([]))
inst_pin = objects.InstanceNUMACell(
diff --git a/nova/virt/hardware.py b/nova/virt/hardware.py
index 0ae1417798..e097c13e9d 100644
--- a/nova/virt/hardware.py
+++ b/nova/virt/hardware.py
@@ -831,8 +831,9 @@ def _numa_fit_instance_cell_with_pinning(host_cell, instance_cell):
else:
# Straightforward to pin to available cpus when there is no
# hyperthreading on the host
+ free_cpus = [set([cpu]) for cpu in host_cell.free_cpus]
return _pack_instance_onto_cores(
- [host_cell.free_cpus], instance_cell, host_cell.id)
+ free_cpus, instance_cell, host_cell.id)
def _numa_fit_instance_cell(host_cell, instance_cell, limit_cell=None):