Skip to content

Commit

Permalink
write back cpu.max.burst after cpu.max modified in cgroup v2
Browse files Browse the repository at this point in the history
If the burst is not set, we need to read the current
value to write it back after `cpu.max` modified.

Signed-off-by: lifubang <[email protected]>
  • Loading branch information
lifubang committed Mar 15, 2024
1 parent 0773673 commit de4e7a4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libcontainer/cgroups/fs2/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ func setCpu(dirPath string, r *configs.Resources) error {
} else {
burst = ""
}
} else {
// If the burst is not set, we need to read the current
// value to write it back after `cpu.max` modified.
if r.CpuQuota != 0 || r.CpuPeriod != 0 {
burst, _ = cgroups.ReadFile(dirPath, "cpu.max.burst")
if burst == "0" {
burst = ""
}
}
}
if r.CpuQuota != 0 || r.CpuPeriod != 0 {
str := "max"
Expand Down

0 comments on commit de4e7a4

Please sign in to comment.