def test_free_cpus_numa(self): obj = objects.NUMATopology(cells=[ objects.NUMANode(id=0, cpuset=set([1, 2]), pinned_cpus=set([1])), objects.NUMANode(id=1, cpuset=set([3, 4]), pinned_cpus=set([])) ]) self.assertEqual(set([2]), obj.cells[0].free_cpus) self.assertEqual(set([3, 4]), obj.cells[1].free_cpus)
def test_cpuset_filter_fail_dedicated_2(self): self.filt_cls = cpuset_filter.CpuSetFilter() container = objects.Container(self.context) container.cpu_policy = 'dedicated' container.cpu = 2.0 container.memory = '1024' host = fakes.FakeHostState('testhost') host.cpus = 6 host.cpu_used = 0.0 host.numa_topology = objects.NUMATopology(nodes=[ objects.NUMANode(id=0, cpuset=set([1, 2, 3]), pinned_cpus=set([]), mem_total=32739, mem_available=32739), objects.NUMANode(id=1, cpuset=set([4, 5, 6]), pinned_cpus=set([]), mem_total=32739, mem_available=32739) ]) host.enable_cpu_pinning = False extra_spec = {} self.assertFalse(self.filt_cls.host_passes(host, container, extra_spec))
def test_pinning_logic(self): numacell = objects.NUMANode(id=0, cpuset=set([1, 2, 3, 4]), pinned_cpus=set([1])) numacell.pin_cpus(set([2, 3])) self.assertEqual(set([4]), numacell.free_cpus) self.assertRaises(exception.CPUUnpinningUnknown, numacell.unpin_cpus, set([1, 55])) self.assertRaises(exception.CPUPinningInvalid, numacell.pin_cpus, set([1, 4])) self.assertRaises(exception.CPUUnpinningInvalid, numacell.unpin_cpus, set([1, 4])) numacell.unpin_cpus(set([1, 2, 3])) self.assertEqual(set([1, 2, 3, 4]), numacell.free_cpus)
def get_host_numa_topology(self, numa_topo_obj): # Replace this call with a more generic call when we obtain other # NUMA related data like memory etc. cpu_info = self.get_cpu_numa_info() floating_cpus = utils.get_floating_cpu_set() numa_node_obj = [] for node, cpuset in cpu_info.items(): numa_node = objects.NUMANode() if floating_cpus: allowed_cpus = set(cpuset) - (floating_cpus & set(cpuset)) else: allowed_cpus = set(cpuset) numa_node.id = node # allowed_cpus are the ones allowed to pin on. # Rest of the cpus are assumed to be floating # in nature. numa_node.cpuset = allowed_cpus numa_node.pinned_cpus = set([]) numa_node_obj.append(numa_node) numa_topo_obj.nodes = numa_node_obj