]> xenbits.xensource.com Git - libvirt.git/commitdiff
virLXCControllerSetupResourceLimits: Call virNuma*() iff needed
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 27 Mar 2015 10:44:55 +0000 (11:44 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 8 Apr 2015 10:01:10 +0000 (12:01 +0200)
Like we are doing in qemu driver (ea576ee543d6fb95583), 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@redhat.com>
src/lxc/lxc_controller.c

index 8545f29d06e4e71f17a4981d442bfad5ef51c6cf..2b5c9dacee7de31c7c78ffbd2a20519697e328dd 100644 (file)
@@ -742,16 +742,26 @@ static int virLXCControllerSetupResourceLimits(virLXCControllerPtr ctrl)
     virBitmapPtr nodeset = NULL;
     virDomainNumatuneMemMode mode;
 
-    VIR_DEBUG("Setting up process resource limits");
+    mode = virDomainNumatuneGetMode(ctrl->def->numa, -1);
 
-    if (virLXCControllerGetNumadAdvice(ctrl, &auto_nodeset) < 0)
-        goto cleanup;
+    if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
+        virCgroupControllerAvailable(VIR_CGROUP_CONTROLLER_CPUSET)) {
+        /* Use virNuma* API iff necessary. Once set and child is exec()-ed,
+         * there's no way for us to change it. Rely on cgroups (if available
+         * and enabled in the config) rather then virNuma*. */
+        VIR_DEBUG("Relying on CGroups for memory binding");
+    } else {
 
-    nodeset = virDomainNumatuneGetNodeset(ctrl->def->numa, auto_nodeset, -1);
-    mode = virDomainNumatuneGetMode(ctrl->def->numa, -1);
+        VIR_DEBUG("Setting up process resource limits");
 
-    if (virNumaSetupMemoryPolicy(mode, nodeset) < 0)
-        goto cleanup;
+        if (virLXCControllerGetNumadAdvice(ctrl, &auto_nodeset) < 0)
+            goto cleanup;
+
+        nodeset = virDomainNumatuneGetNodeset(ctrl->def->numa, auto_nodeset, -1);
+
+        if (virNumaSetupMemoryPolicy(mode, nodeset) < 0)
+            goto cleanup;
+    }
 
     if (virLXCControllerSetupCpuAffinity(ctrl) < 0)
         goto cleanup;