+ cpu_time_percentage = self.single_cu * number_cu
+ # calculate input values for CFS scheduler bandwidth limitation
+ cpu_period, cpu_quota = self._calculate_cpu_cfs_values(cpu_time_percentage)
+ # apply limits to container if changed
+ if d.cpu_period != cpu_period or d.cpu_quota != cpu_quota:
+ LOG.debug("Setting CPU limit for %r: cpu_quota = cpu_period * limit = %f * %f = %f" % (
+ d.name, cpu_period, cpu_time_percentage, cpu_quota))
+ d.updateCpuLimit(cpu_period=int(cpu_period), cpu_quota=int(cpu_quota))
+
+ def _calculate_cpu_cfs_values(self, cpu_time_percentage):
+ """
+ Calculate cpu period and quota for CFS
+ :param cpu_time_percentage: percentage of overall CPU to be used
+ :return: cpu_period, cpu_quota
+ """