support SCHED_IDLE for runc cgroupfs

Signed-off-by: wineway <wangyuweihx@gmail.com>
This commit is contained in:
wineway
2022-05-12 05:43:33 +00:00
parent 8c5d3f09e3
commit 81c379fa8b
9 changed files with 90 additions and 2 deletions
+14 -1
View File
@@ -48,7 +48,8 @@ The accepted format is as follow (unchanged values can be omitted):
"realtimeRuntime": 0,
"realtimePeriod": 0,
"cpus": "",
"mems": ""
"mems": "",
"idle": 0
},
"blockIO": {
"weight": 0
@@ -106,6 +107,10 @@ other options are ignored.
Name: "memory",
Usage: "Memory limit (in bytes)",
},
cli.StringFlag{
Name: "cpu-idle",
Usage: "set cgroup SCHED_IDLE or not, 0: default behavior, 1: SCHED_IDLE",
},
cli.StringFlag{
Name: "memory-reservation",
Usage: "Memory reservation or soft_limit (in bytes)",
@@ -192,6 +197,13 @@ other options are ignored.
if val := context.String("cpuset-mems"); val != "" {
r.CPU.Mems = val
}
if val := context.String("cpu-idle"); val != "" {
idle, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return fmt.Errorf("invalid value for cpu-idle: %w", err)
}
r.CPU.Idle = i64Ptr(idle)
}
for _, pair := range []struct {
opt string
@@ -294,6 +306,7 @@ other options are ignored.
config.Cgroups.Resources.CpusetCpus = r.CPU.Cpus
config.Cgroups.Resources.CpusetMems = r.CPU.Mems
config.Cgroups.Resources.Memory = *r.Memory.Limit
config.Cgroups.Resources.CPUIdle = r.CPU.Idle
config.Cgroups.Resources.MemoryReservation = *r.Memory.Reservation
config.Cgroups.Resources.MemorySwap = *r.Memory.Swap
config.Cgroups.Resources.MemoryCheckBeforeUpdate = *r.Memory.CheckBeforeUpdate