]> xenbits.xensource.com Git - libvirt.git/commitdiff
cgroup: reduce complexity of controller disabling
authorBoris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Thu, 8 Dec 2016 13:24:18 +0000 (14:24 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 20 Dec 2016 10:18:09 +0000 (11:18 +0100)
This patch reduces the complexity of the filtering algorithm in
virCgroupDetect by first correcting the controller mask and then
checking for potential co-mounts without any correlating
controller mask modifications.

If you agree that this patch removes complexity and improves
readability it could simply be squashed into the first patch
of this series.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
src/util/vircgroup.c

index b9d8262aa83e1d07aec5bf534bb4e3b0f7d7e40e..80ce43c1ff5a7aeeab9acfd030d364ab463feb94 100644 (file)
@@ -656,11 +656,8 @@ virCgroupDetect(virCgroupPtr group,
 
     if (controllers >= 0) {
         VIR_DEBUG("Filtering controllers %d", controllers);
+        /* First mark requested but non-existing controllers to be ignored */
         for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
-            VIR_DEBUG("Controller '%s' wanted=%s, mount='%s'",
-                      virCgroupControllerTypeToString(i),
-                      (1 << i) & controllers ? "yes" : "no",
-                      NULLSTR(group->controllers[i].mountPoint));
             if (((1 << i) & controllers)) {
                 /* Remove non-existent controllers  */
                 if (!group->controllers[i].mountPoint) {
@@ -668,12 +665,15 @@ virCgroupDetect(virCgroupPtr group,
                               virCgroupControllerTypeToString(i));
                     controllers &= ~(1 << i);
                 }
-            } else {
-                if (!group->controllers[i].mountPoint) {
-                    /* without controller co-mounting is impossible */
-                    continue;
-                }
-
+            }
+        }
+        for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
+            VIR_DEBUG("Controller '%s' wanted=%s, mount='%s'",
+                      virCgroupControllerTypeToString(i),
+                      (1 << i) & controllers ? "yes" : "no",
+                      NULLSTR(group->controllers[i].mountPoint));
+            if (!((1 << i) & controllers) &&
+                group->controllers[i].mountPoint) {
                 /* Check whether a request to disable a controller
                  * clashes with co-mounting of controllers */
                 for (j = 0; j < VIR_CGROUP_CONTROLLER_LAST; j++) {