Skip to content

Commit

Permalink
fix cpu.cfs_quota_us changed when systemd daemon-reload using systemd.
Browse files Browse the repository at this point in the history
Signed-off-by: xuxinkun <xuxinkun@gmail.com>
  • Loading branch information
xuxinkun committed Feb 24, 2017
1 parent 02141ce commit 9f700d4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libcontainer/cgroups/systemd/apply_systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,19 @@ func (m *Manager) Apply(pid int) error {
newProp("CPUShares", uint64(c.Resources.CpuShares)))
}

// cpu.cfs_quota_us and cpu.cfs_period_us are controlled by systemd.
// The percentage cpuQuota refered specifies how much CPU time the unit
// shall get at maximum, relative to the total CPU time available on one CPU.
// The percentage should be greater than 1%.
if c.Resources.CpuQuota != 0 && c.Resources.CpuPeriod != 0 {
cpuQuota := c.Resources.CpuQuota * 100 / c.Resources.CpuPeriod
if cpuQuota == 0 {
return fmt.Errorf("cpu_quota divided by cpu_period must be greater than 0.01")
}
properties = append(properties,
newProp("CPUQuotaPerSecUSec", uint64(cpuQuota*10000)))
}

if c.Resources.BlkioWeight != 0 {
properties = append(properties,
newProp("BlockIOWeight", uint64(c.Resources.BlkioWeight)))
Expand Down

0 comments on commit 9f700d4

Please sign in to comment.