From 669f9409e594aa24c9528aefd589b7d58eb62989 Mon Sep 17 00:00:00 2001 From: axb Date: Tue, 12 Dec 2023 21:54:40 +0800 Subject: [PATCH] skip set cpu.weight when cpu.idle is enabled in cgroups v2 Signed-off-by: axb --- libcontainer/cgroups/fs2/cpu.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libcontainer/cgroups/fs2/cpu.go b/libcontainer/cgroups/fs2/cpu.go index 8ee49d499f1..8b38a5968e3 100644 --- a/libcontainer/cgroups/fs2/cpu.go +++ b/libcontainer/cgroups/fs2/cpu.go @@ -29,7 +29,8 @@ func setCpu(dirPath string, r *configs.Resources) error { } // NOTE: .CpuShares is not used here. Conversion is the caller's responsibility. - if r.CpuWeight != 0 { + // can not set cpu.weight if cpu.idle is enabled + if r.CpuWeight != 0 && (r.CPUIdle == nil || *r.CPUIdle == 0) { if err := cgroups.WriteFile(dirPath, "cpu.weight", strconv.FormatUint(r.CpuWeight, 10)); err != nil { return err }