[PATCH 2/2] cgroup: reduce complexity of controller disabling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Bjoern Walk <bwalk@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxxxxxxx>
---
 src/util/vircgroup.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 47691e2..80ce43c 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -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,9 +665,15 @@ virCgroupDetect(virCgroupPtr group,
                               virCgroupControllerTypeToString(i));
                     controllers &= ~(1 << i);
                 }
-            } else {
-                if (!group->controllers[i].mountPoint)
-                    continue; /* without controller co-mounting is impossible */
+            }
+        }
+        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++) {
-- 
2.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux