From 8539f493fa06b53596a9dcbec6985c2f4c3701f7 Mon Sep 17 00:00:00 2001 From: Raghavendra K T Date: Sun, 12 Jul 2015 13:16:33 +0530 Subject: [PATCH] Add the memory swappiness tuning option to docker. Memory swappiness option takes 0-100, and helps to tune swappiness behavior per container. For example, When a lower value of swappiness is chosen the container will see minimum major faults. When no value is specified for memory-swappiness in docker UI, it is inherited from parent cgroup. (generally 60 unless it is changed). Signed-off-by: Raghavendra K T --- sysinfo/sysinfo.go | 7 ++++--- sysinfo/sysinfo_linux.go | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sysinfo/sysinfo.go b/sysinfo/sysinfo.go index 47b84ce..8f905aa 100644 --- a/sysinfo/sysinfo.go +++ b/sysinfo/sysinfo.go @@ -13,9 +13,10 @@ type SysInfo struct { } type cgroupMemInfo struct { - MemoryLimit bool - SwapLimit bool - OomKillDisable bool + MemoryLimit bool + SwapLimit bool + OomKillDisable bool + MemorySwappiness bool } type cgroupCpuInfo struct { diff --git a/sysinfo/sysinfo_linux.go b/sysinfo/sysinfo_linux.go index 75700d9..e9d6b3d 100644 --- a/sysinfo/sysinfo_linux.go +++ b/sysinfo/sysinfo_linux.go @@ -50,6 +50,10 @@ func checkCgroupMem(quiet bool) *cgroupMemInfo { if !quiet && !info.OomKillDisable { logrus.Warnf("Your kernel does not support oom control.") } + info.MemorySwappiness = cgroupEnabled(mountPoint, "memory.swappiness") + if !quiet && !info.MemorySwappiness { + logrus.Warnf("Your kernel does not support memory swappiness.") + } return info }