]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu cgroups: move new threads to new cgroup after cpuset is set up
authorHenning Schild <henning.schild@siemens.com>
Mon, 14 Dec 2015 20:58:05 +0000 (15:58 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 14 Dec 2015 20:58:05 +0000 (15:58 -0500)
Moving tasks to cgroups implied sched_setaffinity. Changing the cpus in
a set implies the same for all tasks in the group.
The old code put the the thread into the cpuset inherited from the
machine cgroup, which allowed it to run outside of vcpupin for a short
while.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
src/qemu/qemu_cgroup.c

index 14cf657b7702d5e0bce33d2227d82ae6020cf8f0..1c406ce68e938318ca316d89697065ef6a8f354b 100644 (file)
@@ -1052,11 +1052,6 @@ qemuSetupCgroupForVcpu(virDomainObjPtr vm)
                                true, &cgroup_vcpu) < 0)
             goto cleanup;
 
-        /* move the thread for vcpu to sub dir */
-        if (virCgroupAddTask(cgroup_vcpu,
-                             qemuDomainGetVcpuPid(vm, i)) < 0)
-            goto cleanup;
-
         if (period || quota) {
             if (qemuSetupCgroupVcpuBW(cgroup_vcpu, period, quota) < 0)
                 goto cleanup;
@@ -1090,6 +1085,12 @@ qemuSetupCgroupForVcpu(virDomainObjPtr vm)
             if (qemuSetupCgroupCpusetCpus(cgroup_vcpu, cpumap) < 0)
                 goto cleanup;
         }
+
+        /* move the thread for vcpu to sub dir */
+        if (virCgroupAddTask(cgroup_vcpu,
+                             qemuDomainGetVcpuPid(vm, i)) < 0)
+            goto cleanup;
+
     }
     virCgroupFree(&cgroup_vcpu);
     VIR_FREE(mem_mask);
@@ -1222,11 +1223,6 @@ qemuSetupCgroupForIOThreads(virDomainObjPtr vm)
                                true, &cgroup_iothread) < 0)
             goto cleanup;
 
-        /* move the thread for iothread to sub dir */
-        if (virCgroupAddTask(cgroup_iothread,
-                             def->iothreadids[i]->thread_id) < 0)
-            goto cleanup;
-
         if (period || quota) {
             if (qemuSetupCgroupVcpuBW(cgroup_iothread, period, quota) < 0)
                 goto cleanup;
@@ -1253,6 +1249,11 @@ qemuSetupCgroupForIOThreads(virDomainObjPtr vm)
                 goto cleanup;
         }
 
+        /* move the thread for iothread to sub dir */
+        if (virCgroupAddTask(cgroup_iothread,
+                             def->iothreadids[i]->thread_id) < 0)
+            goto cleanup;
+
         virCgroupFree(&cgroup_iothread);
     }
     VIR_FREE(mem_mask);