[libvirt] [PATCH 6/6] virLXCControllerSetupResourceLimits: Call virNuma*() iff needed

Michal Privoznik mprivozn at redhat.com
Fri Mar 27 14:26:54 UTC 2015


Like we are doing in qemu driver
($COMMIT_HASH_TO_BE_FILLED_DURING_PUSHING), lets call
virNumaSetupMemoryPolicy() only if really needed. Problem is, if
we numa_set_membind() child, there's no way to change it from the
daemon afterwards. So any later attempts to change the pinning
will fail. But in very weird way - CGroups will be set, but due
to membind child will not allocate memory from any other node.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/lxc/lxc_controller.c | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 8545f29..6881a37 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -742,14 +742,33 @@ static int virLXCControllerSetupResourceLimits(virLXCControllerPtr ctrl)
     virBitmapPtr nodeset = NULL;
     virDomainNumatuneMemMode mode;
 
-    VIR_DEBUG("Setting up process resource limits");
-
-    if (virLXCControllerGetNumadAdvice(ctrl, &auto_nodeset) < 0)
-        goto cleanup;
-
-    nodeset = virDomainNumatuneGetNodeset(ctrl->def->numa, auto_nodeset, -1);
     mode = virDomainNumatuneGetMode(ctrl->def->numa, -1);
 
+    if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
+        virCgroupPtr cgroup;
+
+        /* Create dummy cgroup ... */
+        if (virCgroupNewSelf(&cgroup) < 0)
+            goto cleanup;
+
+        /* ... just to detect if cpuset cgroup is present */
+        if (virCgroupHasController(cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
+            /* Because if it's not, we will pin the child onto
+             * specified nodes for good. No later cpuset.mems
+             * change will have any effect. */
+            VIR_DEBUG("Postponing setting up resource limits to CGroup set up phase");
+            virCgroupFree(&cgroup);
+            return virLXCControllerSetupCpuAffinity(ctrl);
+        }
+    }
+
+    VIR_DEBUG("Setting up process resource limits");
+
+    if (virLXCControllerGetNumadAdvice(ctrl, &auto_nodeset) < 0)
+        goto cleanup;
+
+    nodeset = virDomainNumatuneGetNodeset(ctrl->def->numa, auto_nodeset, -1);
+
     if (virNumaSetupMemoryPolicy(mode, nodeset) < 0)
         goto cleanup;
 
-- 
2.0.5




More information about the libvir-list mailing list