mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Fix cfs period calculation
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
(cherry picked from commit aff99136b4
)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
parent
ce22bc39dc
commit
c0ea2c8498
2 changed files with 2 additions and 5 deletions
|
@ -112,11 +112,8 @@ func getCPUResources(config containertypes.Resources) *specs.CPU {
|
|||
}
|
||||
|
||||
if config.NanoCPUs > 0 {
|
||||
// We set the highest value possible (1s), as is specified in:
|
||||
// https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt
|
||||
// cpu.cfs_period_us=1s
|
||||
// The purpose is to get the highest precision
|
||||
period := uint64(1 * time.Second / time.Microsecond)
|
||||
period := uint64(100 * time.Millisecond / time.Microsecond)
|
||||
quota := uint64(config.NanoCPUs) * period / 1e9
|
||||
cpu.Period = &period
|
||||
cpu.Quota = "a
|
||||
|
|
|
@ -1577,7 +1577,7 @@ func (s *DockerSuite) TestRunWithNanoCPUs(c *check.C) {
|
|||
file1 := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us"
|
||||
file2 := "/sys/fs/cgroup/cpu/cpu.cfs_period_us"
|
||||
out, _ := dockerCmd(c, "run", "--cpus", "0.5", "--name", "test", "busybox", "sh", "-c", fmt.Sprintf("cat %s && cat %s", file1, file2))
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, "500000\n1000000")
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, "50000\n100000")
|
||||
|
||||
out = inspectField(c, "test", "HostConfig.NanoCpus")
|
||||
c.Assert(out, checker.Equals, "5e+08", check.Commentf("setting the Nano CPUs failed"))
|
||||
|
|
Loading…
Reference in a new issue