Skip to content

Commit

Permalink
feat: use memory.peak and memory.swap.peak in cgroups v2
Browse files Browse the repository at this point in the history
Signed-off-by: HeRaNO <[email protected]>
  • Loading branch information
HeRaNO committed Sep 9, 2023
1 parent e897a16 commit b137e99
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libcontainer/cgroups/fs2/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func getMemoryDataV2(path, name string) (cgroups.MemoryData, error) {
}
usage := moduleName + ".current"
limit := moduleName + ".max"
maxUsage := moduleName + ".peak"

value, err := fscommon.GetCgroupParamUint(path, usage)
if err != nil {
Expand All @@ -157,6 +158,14 @@ func getMemoryDataV2(path, name string) (cgroups.MemoryData, error) {
}
memoryData.Limit = value

// `memory.peak` since kernel 5.19
// `memory.swap.peak` since kernel 6.5
value, err = fscommon.GetCgroupParamUint(path, maxUsage)
if err != nil && !os.IsNotExist(err) {
return cgroups.MemoryData{}, err
}
memoryData.MaxUsage = value

return memoryData, nil
}

Expand Down

0 comments on commit b137e99

Please sign in to comment.