Add support for memory reservation

Signed-off-by: qhuang <qhuang@10.0.2.15>
This commit is contained in:
qhuang 2015-09-23 14:02:45 +08:00
parent 22afd88a00
commit f0bff37edc
2 changed files with 13 additions and 5 deletions

View file

@ -31,6 +31,9 @@ type cgroupMemInfo struct {
// Whether swap limit is supported or not // Whether swap limit is supported or not
SwapLimit bool SwapLimit bool
// Whether soft limit is supported or not
MemoryReservation bool
// Whether OOM killer disalbe is supported or not // Whether OOM killer disalbe is supported or not
OomKillDisable bool OomKillDisable bool

View file

@ -49,6 +49,10 @@ func checkCgroupMem(quiet bool) cgroupMemInfo {
if !quiet && !swapLimit { if !quiet && !swapLimit {
logrus.Warn("Your kernel does not support swap memory limit.") logrus.Warn("Your kernel does not support swap memory limit.")
} }
memoryReservation := cgroupEnabled(mountPoint, "memory.soft_limit_in_bytes")
if !quiet && !memoryReservation {
logrus.Warn("Your kernel does not support memory reservation.")
}
oomKillDisable := cgroupEnabled(mountPoint, "memory.oom_control") oomKillDisable := cgroupEnabled(mountPoint, "memory.oom_control")
if !quiet && !oomKillDisable { if !quiet && !oomKillDisable {
logrus.Warnf("Your kernel does not support oom control.") logrus.Warnf("Your kernel does not support oom control.")
@ -63,11 +67,12 @@ func checkCgroupMem(quiet bool) cgroupMemInfo {
} }
return cgroupMemInfo{ return cgroupMemInfo{
MemoryLimit: true, MemoryLimit: true,
SwapLimit: swapLimit, SwapLimit: swapLimit,
OomKillDisable: oomKillDisable, MemoryReservation: memoryReservation,
MemorySwappiness: memorySwappiness, OomKillDisable: oomKillDisable,
KernelMemory: kernelMemory, MemorySwappiness: memorySwappiness,
KernelMemory: kernelMemory,
} }
} }