Add cpuset_reserved helper to instance NUMA topology

When we pin emulator threads with the `isolate` policy, those pins are
stored in the `cpuset_reserved` field in each NUMACell. In subsequent
patches we'll need those pins for the whole instance, so this patch
adds a helper property that does this for us, similar to how the
`cpu_pinning` property helper currently works.

Related-bug: 2056612
Change-Id: I8597f13e8089106434018b94e9bbc2091f95fee9
(cherry picked from commit 8dbfecd663)
This commit is contained in:
Artom Lifshitz 2024-02-23 10:04:02 -05:00
parent 45a926156c
commit 62a35d2324
2 changed files with 14 additions and 2 deletions

View File

@ -293,6 +293,12 @@ class InstanceNUMATopology(base.NovaObject,
cell.cpu_pinning.values() for cell in self.cells
if cell.cpu_pinning]))
@property
def cpuset_reserved(self):
return set(itertools.chain.from_iterable([
cell.cpuset_reserved for cell in self.cells
if cell.cpuset_reserved]))
def clear_host_pinning(self):
"""Clear any data related to how instance is pinned to the host.

View File

@ -29,10 +29,12 @@ fake_obj_numa_topology = objects.InstanceNUMATopology(
instance_uuid=fake_instance_uuid,
cells=[
objects.InstanceNUMACell(
id=0, cpuset=set(), pcpuset=set([1, 2]), memory=512,
id=0, cpuset=set(), pcpuset=set([1, 2]),
cpuset_reserved=set([5, 6]), memory=512,
pagesize=2048),
objects.InstanceNUMACell(
id=1, cpuset=set(), pcpuset=set([3, 4]), memory=512,
id=1, cpuset=set(), pcpuset=set([3, 4]),
cpuset_reserved=set([7, 8]), memory=512,
pagesize=2048),
])
@ -155,6 +157,10 @@ class _TestInstanceNUMACell(object):
topo_obj.cells[1].pin_vcpus((3, 0), (4, 1))
self.assertEqual(set([0, 1, 10, 11]), topo_obj.cpu_pinning)
def test_cpuset_reserved(self):
topo_obj = get_fake_obj_numa_topology(self.context)
self.assertEqual(set([5, 6, 7, 8]), topo_obj.cpuset_reserved)
def test_clear_host_pinning(self):
topo_obj = get_fake_obj_numa_topology(self.context)
topo_obj.cells[0].pin_vcpus((1, 10), (2, 11))