From f0bff37edcc3d880dd003cb6a2d222a53b202ebf Mon Sep 17 00:00:00 2001 From: qhuang Date: Wed, 23 Sep 2015 14:02:45 +0800 Subject: [PATCH] Add support for memory reservation Signed-off-by: qhuang --- sysinfo/sysinfo.go | 3 +++ sysinfo/sysinfo_linux.go | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/sysinfo/sysinfo.go b/sysinfo/sysinfo.go index c4ca4a2..e62eadf 100644 --- a/sysinfo/sysinfo.go +++ b/sysinfo/sysinfo.go @@ -31,6 +31,9 @@ type cgroupMemInfo struct { // Whether swap limit is supported or not SwapLimit bool + // Whether soft limit is supported or not + MemoryReservation bool + // Whether OOM killer disalbe is supported or not OomKillDisable bool diff --git a/sysinfo/sysinfo_linux.go b/sysinfo/sysinfo_linux.go index 84e3ceb..44f10fa 100644 --- a/sysinfo/sysinfo_linux.go +++ b/sysinfo/sysinfo_linux.go @@ -49,6 +49,10 @@ func checkCgroupMem(quiet bool) cgroupMemInfo { if !quiet && !swapLimit { 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") if !quiet && !oomKillDisable { logrus.Warnf("Your kernel does not support oom control.") @@ -63,11 +67,12 @@ func checkCgroupMem(quiet bool) cgroupMemInfo { } return cgroupMemInfo{ - MemoryLimit: true, - SwapLimit: swapLimit, - OomKillDisable: oomKillDisable, - MemorySwappiness: memorySwappiness, - KernelMemory: kernelMemory, + MemoryLimit: true, + SwapLimit: swapLimit, + MemoryReservation: memoryReservation, + OomKillDisable: oomKillDisable, + MemorySwappiness: memorySwappiness, + KernelMemory: kernelMemory, } }