File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
libcontainer/cgroups/systemd Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,13 @@ func (m *Manager) Apply(pid int) error {
271271 // cpu.cfs_quota_us and cpu.cfs_period_us are controlled by systemd.
272272 if c .Resources .CpuQuota != 0 && c .Resources .CpuPeriod != 0 {
273273 cpuQuotaPerSecUSec := uint64 (c .Resources .CpuQuota * 1000000 ) / c .Resources .CpuPeriod
274+ // systemd converts CPUQuotaPerSecUSec (microseconds per CPU second) to CPUQuota
275+ // (integer percentage of CPU) internally. This means that if a fractional percent of
276+ // CPU is indicated by Resources.CpuQuota, we need to round up to the nearest
277+ // 10ms (1% of a second) such that child cgroups can set the cpu.cfs_quota_us they expect.
278+ if cpuQuotaPerSecUSec % 10000 != 0 {
279+ cpuQuotaPerSecUSec = ((cpuQuotaPerSecUSec / 10000 ) + 1 ) * 10000
280+ }
274281 properties = append (properties ,
275282 newProp ("CPUQuotaPerSecUSec" , cpuQuotaPerSecUSec ))
276283 }
You can’t perform that action at this time.
0 commit comments