File tree 1 file changed +13
-0
lines changed
libcontainer/cgroups/systemd
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -269,6 +269,19 @@ func (m *Manager) Apply(pid int) error {
269
269
newProp ("CPUShares" , uint64 (c .Resources .CpuShares )))
270
270
}
271
271
272
+ // cpu.cfs_quota_us and cpu.cfs_period_us are controlled by systemd.
273
+ // The percentage cpuQuota refered specifies how much CPU time the unit
274
+ // shall get at maximum, relative to the total CPU time available on one CPU.
275
+ // The percentage should be greater than 1%.
276
+ if c .Resources .CpuQuota != 0 && c .Resources .CpuPeriod != 0 {
277
+ cpuQuota := c .Resources .CpuQuota * 100 / c .Resources .CpuPeriod
278
+ if cpuQuota == 0 {
279
+ return fmt .Errorf ("cpu_quota divided by cpu_period must be greater than 0.01" )
280
+ }
281
+ properties = append (properties ,
282
+ newProp ("CPUQuotaPerSecUSec" , uint64 (cpuQuota * 10000 )))
283
+ }
284
+
272
285
if c .Resources .BlkioWeight != 0 {
273
286
properties = append (properties ,
274
287
newProp ("BlockIOWeight" , uint64 (c .Resources .BlkioWeight )))
You can’t perform that action at this time.
0 commit comments