提交 f0fa9080 编写于 作者: P Peter Krempa

qemu: cgroup: Properly set up vcpu pinning

When the default cpuset or automatic numa placement is used libvirt
would place the whole parent cgroup in the specified cpuset. This then
disallowed to re-pin the vcpus to a different cpu.

This patch pins only the vcpu threads to the default cpuset and thus
allows to re-pin them later.

The following config would fail to start:
<domain type='kvm'>
  ...
  <vcpu placement='static' cpuset='0-1' current='2'>4</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='2-3'/>
    ...

This is a regression since a39f69d2.
上级 70950069
...@@ -645,8 +645,6 @@ static int ...@@ -645,8 +645,6 @@ static int
qemuSetupCpusetCgroup(virDomainObjPtr vm) qemuSetupCpusetCgroup(virDomainObjPtr vm)
{ {
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
char *cpu_mask = NULL;
int ret = -1;
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET))
return 0; return 0;
...@@ -654,25 +652,7 @@ qemuSetupCpusetCgroup(virDomainObjPtr vm) ...@@ -654,25 +652,7 @@ qemuSetupCpusetCgroup(virDomainObjPtr vm)
if (virCgroupSetCpusetMemoryMigrate(priv->cgroup, true) < 0) if (virCgroupSetCpusetMemoryMigrate(priv->cgroup, true) < 0)
return -1; return -1;
if (vm->def->cpumask || return 0;
(vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO)) {
if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO)
cpu_mask = virBitmapFormat(priv->autoCpuset);
else
cpu_mask = virBitmapFormat(vm->def->cpumask);
if (!cpu_mask)
goto cleanup;
if (virCgroupSetCpusetCpus(priv->cgroup, cpu_mask) < 0)
goto cleanup;
}
ret = 0;
cleanup:
VIR_FREE(cpu_mask);
return ret;
} }
...@@ -1079,20 +1059,27 @@ qemuSetupCgroupForVcpu(virDomainObjPtr vm) ...@@ -1079,20 +1059,27 @@ qemuSetupCgroupForVcpu(virDomainObjPtr vm)
/* Set vcpupin in cgroup if vcpupin xml is provided */ /* Set vcpupin in cgroup if vcpupin xml is provided */
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
/* find the right CPU to pin, otherwise virBitmapPtr cpumap = NULL;
* qemuSetupCgroupVcpuPin will fail. */
for (j = 0; j < def->cputune.nvcpupin; j++) {
if (def->cputune.vcpupin[j]->id != i)
continue;
if (qemuSetupCgroupVcpuPin(cgroup_vcpu, /* try to use the default cpu maps */
def->cputune.vcpupin, if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO)
def->cputune.nvcpupin, cpumap = priv->autoCpuset;
i) < 0) else
goto cleanup; cpumap = vm->def->cpumask;
break; /* lookup a more specific pinning info */
for (j = 0; j < def->cputune.nvcpupin; j++) {
if (def->cputune.vcpupin[j]->id == i) {
cpumap = def->cputune.vcpupin[j]->cpumask;
break;
}
} }
if (!cpumap)
continue;
if (qemuSetupCgroupEmulatorPin(cgroup_vcpu, cpumap) < 0)
goto cleanup;
} }
virCgroupFree(&cgroup_vcpu); virCgroupFree(&cgroup_vcpu);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册