Modify working set memory stats calculation

Change working set calculation to usage - total_inactive_file, rather than
usage - total_inactive_anon - total_inactive_file. Since writes to tmpfs
get tracked as total_inactive_anon when swap is disabled, the old
calculation would under-report memory pressure.

See this Kubernetes issue for context:
https://github.com/kubernetes/kubernetes/issues/28619
This commit is contained in:
Michael Taufen 2016-07-15 08:42:04 -07:00
parent b37f9970ef
commit 307d1b1cb3

View File

@ -387,23 +387,16 @@ func toContainerStats2(s *cgroups.Stats, ret *info.ContainerStats) {
ret.Memory.ContainerData.Pgmajfault = v ret.Memory.ContainerData.Pgmajfault = v
ret.Memory.HierarchicalData.Pgmajfault = v ret.Memory.HierarchicalData.Pgmajfault = v
} }
if v, ok := s.MemoryStats.Stats["total_inactive_anon"]; ok {
workingSet := ret.Memory.Usage workingSet := ret.Memory.Usage
if v, ok := s.MemoryStats.Stats["total_inactive_file"]; ok {
if workingSet < v { if workingSet < v {
workingSet = 0 workingSet = 0
} else { } else {
workingSet -= v workingSet -= v
} }
if v, ok := s.MemoryStats.Stats["total_inactive_file"]; ok {
if workingSet < v {
workingSet = 0
} else {
workingSet -= v
}
}
ret.Memory.WorkingSet = workingSet
} }
ret.Memory.WorkingSet = workingSet
} }
func toContainerStats3(libcontainerStats *libcontainer.Stats, ret *info.ContainerStats) { func toContainerStats3(libcontainerStats *libcontainer.Stats, ret *info.ContainerStats) {