Status: New
Owner: ----

New issue 1129 by [email protected]: LXC: enable CPU bandwidth control (aka capping)
https://code.google.com/p/ganeti/issues/detail?id=1129

Hi,

currently the LXC hypervisor supports only CPU pinning. The assigned backend parameter "vcpus" is mostly ignored. Instead of manual pinning to physical CPUs, the cpu cgroup allows bandwidth control of CPU usage[1]. The instance's assigned VCPUs can be directly translated into CFS quota. The following is a quick hack to make this working:

--- a/lib/hypervisor/hv_lxc.py  2015-07-07 10:35:58.000000000 +0200
+++ b/lib/hypervisor/hv_lxc.py  2015-10-06 12:21:50.000000000 +0200
@@ -578,7 +578,7 @@
     out.append("lxc.mount.entry = proc proc proc nodev,noexec,nosuid 0 0")
     out.append("lxc.mount.entry = sysfs sys sysfs defaults 0 0")

-    # CPUs
+    # pinned CPUs
     if instance.hvparams[constants.HV_CPU_MASK]:
cpu_list = utils.ParseCpuMask(instance.hvparams[constants.HV_CPU_MASK])
       cpus_in_mask = len(cpu_list)
@@ -590,6 +590,15 @@
                                       cpus_in_mask))
       out.append("lxc.cgroup.cpuset.cpus = %s" %
                  instance.hvparams[constants.HV_CPU_MASK])
+    # not pinned, but limited CPUs
+    else:
+      # https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.tx:
+      # By using a small period here we are ensuring a consistent latency
+      # response
+      period = 50000
+      out.append("# capped to %s CPUs" % instance.beparams["vcpus"])
+      out.append("lxc.cgroup.cpu.cfs_period_us = %s" % period)
+      quota = period * instance.beparams["vcpus"]
+      out.append("lxc.cgroup.cpu.cfs_quota_us = %s" % quota)

Maybe this is useful for someone else. Thanks, Sascha.

[1] https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt


--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

Reply via email to