Skip to content

Commit

Permalink
refactor(util): set non-root cgroup memory.max
Browse files Browse the repository at this point in the history
Signed-off-by: linzhecheng <linzhecheng@bytedance.com>
  • Loading branch information
cheney-lin committed Apr 22, 2024
1 parent 71a36f6 commit 7d92eb3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ func refaultPolicyFunc(lastStats TmoStats, currStats TmoStats, conf *tmoconf.TMO
// Decrease offloading size if detecting the reclaim accuracy or scan efficiency is below the targets
return nil, math.Max(0, currStats.lastOffloadingTargetSize*reclaimAccuracyRatio)
} else {
// Try to increase offloading size but make sure not exceed the max probe of memory usage and 10% of inactive memory
// Try to increase offloading size but make sure not exceed the max probe of memory usage and 10% of inactive memory when the target size of last round is relatively small,
// which means reclaim accuracy and reclaim scan efficiency is low.
return nil, math.Min(math.Max(currStats.lastOffloadingTargetSize*OffloadingSizeScaleCoeff, currStats.memInactive*InactiveProbe), currStats.memUsage*conf.RefaultPolicyConf.MaxProbe)
}
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/util/cgroup/manager/cgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func SetSwapMaxWithAbsolutePathToParentCgroupRecursive(absCgroupPath string) err
}

parentDir := filepath.Dir(absCgroupPath)
if parentDir != absCgroupPath {
if parentDir != absCgroupPath && parentDir != common.GetCgroupRootPath(common.CgroupSubsysMemory) {
err = SetSwapMaxWithAbsolutePathToParentCgroupRecursive(parentDir)
if err != nil {
return err
Expand All @@ -333,7 +333,9 @@ func SetSwapMaxWithAbsolutePathRecursive(absCgroupPath string) error {
general.Infof("[SetSwapMaxWithAbsolutePathRecursive] on cgroup: %s", absCgroupPath)

// set swap max to parent cgroups recursively
_ = SetSwapMaxWithAbsolutePathToParentCgroupRecursive(filepath.Dir(absCgroupPath))
if err := SetSwapMaxWithAbsolutePathToParentCgroupRecursive(filepath.Dir(absCgroupPath)); err != nil {
return err
}

// set swap max to sub cgroups recursively
err := filepath.Walk(absCgroupPath, func(path string, info fs.FileInfo, err error) error {
Expand Down

0 comments on commit 7d92eb3

Please sign in to comment.