mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemu, ch: Move threads to cgroup dir before changing parameters
With cgroupv2 this has better effect on the resource allocation. An excerpt from Documentation/admin-guide/cgroup-v2.rst explains is this way: Migrating a process across cgroups is a relatively expensive operation and stateful resources such as memory are not moved together with the process. This is an explicit design decision as there often exist inherent trade-offs between migration and various hot paths in terms of synchronization cost. [...] Setting a non-empty value to "cpuset.mems" causes memory of tasks within the cgroup to be migrated to the designated nodes if they are currently using memory outside of the designated nodes. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
d2af152d1f
commit
383caddea1
@ -262,6 +262,12 @@ virCHProcessSetupPid(virDomainObj *vm,
|
|||||||
if (virCgroupNewThread(priv->cgroup, nameval, id, true, &cgroup) < 0)
|
if (virCgroupNewThread(priv->cgroup, nameval, id, true, &cgroup) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
/* Move the thread to the sub dir before changing the settings so that
|
||||||
|
* all take effect even with cgroupv2. */
|
||||||
|
VIR_INFO("Adding pid %d to cgroup", pid);
|
||||||
|
if (virCgroupAddThread(cgroup, pid) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
|
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
|
||||||
if (use_cpumask &&
|
if (use_cpumask &&
|
||||||
virDomainCgroupSetupCpusetCpus(cgroup, use_cpumask) < 0)
|
virDomainCgroupSetupCpusetCpus(cgroup, use_cpumask) < 0)
|
||||||
@ -274,12 +280,6 @@ virCHProcessSetupPid(virDomainObj *vm,
|
|||||||
|
|
||||||
if (virDomainCgroupSetupVcpuBW(cgroup, period, quota) < 0)
|
if (virDomainCgroupSetupVcpuBW(cgroup, period, quota) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* Move the thread to the sub dir */
|
|
||||||
VIR_INFO("Adding pid %d to cgroup", pid);
|
|
||||||
if (virCgroupAddThread(cgroup, pid) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!affinity_cpumask)
|
if (!affinity_cpumask)
|
||||||
|
@ -2630,6 +2630,11 @@ qemuProcessSetupPid(virDomainObj *vm,
|
|||||||
if (virCgroupNewThread(priv->cgroup, nameval, id, true, &cgroup) < 0)
|
if (virCgroupNewThread(priv->cgroup, nameval, id, true, &cgroup) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
/* Move the thread to the sub dir before changing the settings so that
|
||||||
|
* all take effect even with cgroupv2. */
|
||||||
|
if (virCgroupAddThread(cgroup, pid) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
|
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
|
||||||
if (use_cpumask &&
|
if (use_cpumask &&
|
||||||
virDomainCgroupSetupCpusetCpus(cgroup, use_cpumask) < 0)
|
virDomainCgroupSetupCpusetCpus(cgroup, use_cpumask) < 0)
|
||||||
@ -2642,11 +2647,6 @@ qemuProcessSetupPid(virDomainObj *vm,
|
|||||||
|
|
||||||
if (virDomainCgroupSetupVcpuBW(cgroup, period, quota) < 0)
|
if (virDomainCgroupSetupVcpuBW(cgroup, period, quota) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* Move the thread to the sub dir */
|
|
||||||
if (virCgroupAddThread(cgroup, pid) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!affinity_cpumask)
|
if (!affinity_cpumask)
|
||||||
|
Loading…
Reference in New Issue
Block a user