numa: update numa usage to include reserved CPUs

We have reserved pCPUs now we should update the host topology
according that reservation.

implements blueprint libvirt-emulator-threads-policy

Change-Id: I7a801a5544e1139d932ea32a19ff70bcf3365ece
This commit is contained in:
Sahid Orentino Ferdjaoui
2016-11-22 10:58:29 -05:00
parent d58515c905
commit f6f1bac379
2 changed files with 57 additions and 1 deletions

View File

@@ -1589,7 +1589,7 @@ def numa_usage_from_instances(host, instances, free=False):
pinned_cpus=hostcell.pinned_cpus, siblings=hostcell.siblings)
for instance in instances:
for instancecell in instance.cells:
for cellid, instancecell in enumerate(instance.cells):
if instancecell.id == hostcell.id:
memory_usage = (
memory_usage + sign * instancecell.memory)
@@ -1600,11 +1600,22 @@ def numa_usage_from_instances(host, instances, free=False):
cpu_usage_diff *= max(map(len, hostcell.siblings))
cpu_usage += sign * cpu_usage_diff
if (cellid == 0
and instance.emulator_threads_isolated):
# The emulator threads policy when defined
# with 'isolate' makes the instance to consume
# an additional pCPU as overhead. That pCPU is
# mapped on the host NUMA node related to the
# guest NUMA node 0.
cpu_usage += sign * len(instancecell.cpuset_reserved)
if instancecell.pagesize and instancecell.pagesize > 0:
newcell.mempages = _numa_pagesize_usage_from_cell(
hostcell, instancecell, sign)
if instance.cpu_pinning_requested:
pinned_cpus = set(instancecell.cpu_pinning.values())
if instancecell.cpuset_reserved:
pinned_cpus |= instancecell.cpuset_reserved
if free:
if (instancecell.cpu_thread_policy ==
fields.CPUThreadAllocationPolicy.ISOLATE):