From 8928d487defbc916d145d83d9cbde3d3aef3993e Mon Sep 17 00:00:00 2001 From: Victor Marmol Date: Mon, 11 May 2015 09:43:11 -0700 Subject: [PATCH 1/2] Min working set should be 0. Fixes #685 --- container/libcontainer/helpers.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/container/libcontainer/helpers.go b/container/libcontainer/helpers.go index d5bf142a..560d8eb6 100644 --- a/container/libcontainer/helpers.go +++ b/container/libcontainer/helpers.go @@ -186,10 +186,21 @@ func toContainerStats2(s *cgroups.Stats, ret *info.ContainerStats) { ret.Memory.HierarchicalData.Pgmajfault = v } if v, ok := s.MemoryStats.Stats["total_inactive_anon"]; ok { - ret.Memory.WorkingSet = ret.Memory.Usage - v - if v, ok := s.MemoryStats.Stats["total_active_file"]; ok { - ret.Memory.WorkingSet -= v + workingSet := ret.Memory.Usage + if workingSet < v { + workingSet = 0 + } else { + workingSet -= v } + + if v, ok := s.MemoryStats.Stats["total_active_file"]; ok { + if workingSet < v { + workingSet = 0 + } else { + workingSet -= v + } + } + ret.Memory.WorkingSet = workingSet } } From 757ad9e1ae8185bda5ccd2ff3ec712c9c9378cab Mon Sep 17 00:00:00 2001 From: Victor Marmol Date: Mon, 11 May 2015 09:44:49 -0700 Subject: [PATCH 2/2] WorkingSet should use inactive file --- container/libcontainer/helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/container/libcontainer/helpers.go b/container/libcontainer/helpers.go index 560d8eb6..f2ceb2b7 100644 --- a/container/libcontainer/helpers.go +++ b/container/libcontainer/helpers.go @@ -193,7 +193,7 @@ func toContainerStats2(s *cgroups.Stats, ret *info.ContainerStats) { workingSet -= v } - if v, ok := s.MemoryStats.Stats["total_active_file"]; ok { + if v, ok := s.MemoryStats.Stats["total_inactive_file"]; ok { if workingSet < v { workingSet = 0 } else {