[PATCH 1/5] util: vircgroup: pass parent cgroup into virCgroupDetectControllersCB

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

 



In cgroups v2 we don't have to detect available controllers every single
time if we are creating a new cgroup based on parent cgroup.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/util/vircgroup.c        |  2 +-
 src/util/vircgroupbackend.h |  3 ++-
 src/util/vircgroupv1.c      |  3 ++-
 src/util/vircgroupv2.c      | 17 +++++++++++------
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index f58e336404..bb7452d2a0 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -383,7 +383,7 @@ virCgroupDetect(virCgroupPtr group,
 
     for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
         if (group->backends[i]) {
-            int rc = group->backends[i]->detectControllers(group, controllers);
+            int rc = group->backends[i]->detectControllers(group, controllers, parent);
             if (rc < 0)
                 return -1;
             controllersAvailable |= rc;
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index e58e327c68..1fe0851184 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -95,7 +95,8 @@ typedef char *
 
 typedef int
 (*virCgroupDetectControllersCB)(virCgroupPtr group,
-                                int controllers);
+                                int controllers,
+                                virCgroupPtr parent);
 
 typedef bool
 (*virCgroupHasControllerCB)(virCgroupPtr cgroup,
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 8ce10d3608..3c195f69ce 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -420,7 +420,8 @@ virCgroupV1StealPlacement(virCgroupPtr group)
 
 static int
 virCgroupV1DetectControllers(virCgroupPtr group,
-                             int controllers)
+                             int controllers,
+                             virCgroupPtr parent ATTRIBUTE_UNUSED)
 {
     size_t i;
     size_t j;
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 0cfbc96264..671a078b23 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -285,16 +285,21 @@ virCgroupV2ParseControllersFile(virCgroupPtr group)
 
 static int
 virCgroupV2DetectControllers(virCgroupPtr group,
-                             int controllers)
+                             int controllers,
+                             virCgroupPtr parent)
 {
     size_t i;
 
-    if (virCgroupV2ParseControllersFile(group) < 0)
-        return -1;
+    if (parent) {
+        group->unified.controllers = parent->unified.controllers;
+    } else {
+        if (virCgroupV2ParseControllersFile(group) < 0)
+            return -1;
 
-    /* In cgroup v2 there is no cpuacct controller, the cpu.stat file always
-     * exists with usage stats. */
-    group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_CPUACCT;
+        /* In cgroup v2 there is no cpuacct controller, the cpu.stat file always
+         * exists with usage stats. */
+        group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_CPUACCT;
+    }
 
     for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++)
         VIR_DEBUG("Controller '%s' present=%s",
-- 
2.21.0

--
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