Skip to content

Commit

Permalink
Merge pull request #2810 from odinuge/cgroup-v2-memory-stat
Browse files Browse the repository at this point in the history
Fix memory stats for cgroup v2
  • Loading branch information
bobbypage authored Mar 2, 2021
2 parents f7b7123 + 691ca31 commit 5c551bc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion container/libcontainer/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,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"]
Expand Down

0 comments on commit 5c551bc

Please sign in to comment.