diff --git a/container/libcontainer/handler.go b/container/libcontainer/handler.go index 1094b10392..2f49abc273 100644 --- a/container/libcontainer/handler.go +++ b/container/libcontainer/handler.go @@ -834,7 +834,12 @@ func setMemoryStats(s *cgroups.Stats, ret *info.ContainerStats) { ret.Memory.MaxUsage = s.MemoryStats.Usage.MaxUsage ret.Memory.Failcnt = s.MemoryStats.Usage.Failcnt - if s.MemoryStats.UseHierarchy { + if cgroups.IsCgroup2UnifiedMode() { + ret.Memory.Cache = s.MemoryStats.Stats["file"] + ret.Memory.RSS = s.MemoryStats.Stats["anon"] + ret.Memory.Swap = s.MemoryStats.SwapUsage.Usage + ret.Memory.MappedFile = s.MemoryStats.Stats["file_mapped"] + } else if s.MemoryStats.UseHierarchy { ret.Memory.Cache = s.MemoryStats.Stats["total_cache"] ret.Memory.RSS = s.MemoryStats.Stats["total_rss"] ret.Memory.Swap = s.MemoryStats.Stats["total_swap"]