Add memory reservation support for systemd

Seems it's missed in the first place.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
Qiang Huang
2015-09-29 10:02:12 +08:00
parent 902ccd0f18
commit fb5a56fb97
@@ -176,7 +176,6 @@ func (m *Manager) Apply(pid int) error {
properties = append(properties,
newProp("MemoryLimit", uint64(c.Memory)))
}
// TODO: MemoryReservation and MemorySwap not available in systemd
if c.CpuShares != 0 {
properties = append(properties,
@@ -212,6 +211,7 @@ func (m *Manager) Apply(pid int) error {
return err
}
// TODO: MemoryReservation and MemorySwap not available in systemd
if err := joinMemory(c, pid); err != nil {
return err
}
@@ -505,6 +505,12 @@ func joinMemory(c *configs.Cgroup, pid int) error {
return err
}
}
if c.MemoryReservation > 0 {
err = writeFile(path, "memory.soft_limit_in_bytes", strconv.FormatInt(c.MemoryReservation, 10))
if err != nil {
return err
}
}
if c.OomKillDisable {
if err := writeFile(path, "memory.oom_control", "1"); err != nil {
return err