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,14 +387,8 @@ func toContainerStats2(s *cgroups.Stats, ret *info.ContainerStats) {
ret.Memory.ContainerData.Pgmajfault = v
ret.Memory.HierarchicalData.Pgmajfault = v
}
if v, ok := s.MemoryStats.Stats["total_inactive_anon"]; ok {
workingSet := ret.Memory.Usage
if workingSet < v {
workingSet = 0
} else {
workingSet -= v
}
workingSet := ret.Memory.Usage
if v, ok := s.MemoryStats.Stats["total_inactive_file"]; ok {
if workingSet < v {
workingSet = 0
@ -403,7 +397,6 @@ func toContainerStats2(s *cgroups.Stats, ret *info.ContainerStats) {
}
}
ret.Memory.WorkingSet = workingSet
}
}
func toContainerStats3(libcontainerStats *libcontainer.Stats, ret *info.ContainerStats) {