Skip to content

Commit e3ba943

Browse files
authored
Merge pull request #1173 from WeiZhang555/update-rt-resources
Allow update rt_period_us and rt_runtime_us
2 parents ac031b5 + 6cd425b commit e3ba943

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

man/runc-update.8.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ accepted format is as follow (unchanged values can be omitted):
2020
"shares": 0,
2121
"quota": 0,
2222
"period": 0,
23+
"realtimeRuntime": 0,
24+
"realtimePeriod": 0,
2325
"cpus": "",
2426
"mems": ""
2527
},
@@ -34,8 +36,10 @@ other options are ignored.
3436
# OPTIONS
3537
--resources value, -r value path to the file containing the resources to update or '-' to read from the standard input
3638
--blkio-weight value Specifies per cgroup weight, range is from 10 to 1000 (default: 0)
37-
--cpu-period value CPU period to be used for hardcapping (in usecs). 0 to use system default
38-
--cpu-quota value CPU hardcap limit (in usecs). Allowed cpu time in a given period
39+
--cpu-period value CPU CFS period to be used for hardcapping (in usecs). 0 to use system default
40+
--cpu-quota value CPU CFS hardcap limit (in usecs). Allowed cpu time in a given period
41+
--cpu-rt-period value CPU realtime period to be used for hardcapping (in usecs). 0 to use system default
42+
--cpu-rt-runtime value CPU realtime hardcap limit (in usecs). Allowed cpu time in a given period
3943
--cpu-share value CPU shares (relative weight vs. other containers)
4044
--cpuset-cpus value CPU(s) to use
4145
--cpuset-mems value Memory node(s) to use

tests/integration/update.bats

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function check_cgroup_value() {
4747
[ "$current" -eq "$expected" ]
4848
}
4949

50+
# TODO: test rt cgroup updating
5051
@test "update" {
5152
requires cgroups_kmem
5253
# run a few busyboxes detached

update.go

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ The accepted format is as follow (unchanged values can be omitted):
4040
"shares": 0,
4141
"quota": 0,
4242
"period": 0,
43+
"realtimeRuntime": 0,
44+
"realtimePeriod": 0,
4345
"cpus": "",
4446
"mems": ""
4547
},
@@ -59,16 +61,24 @@ other options are ignored.
5961
},
6062
cli.StringFlag{
6163
Name: "cpu-period",
62-
Usage: "CPU period to be used for hardcapping (in usecs). 0 to use system default",
64+
Usage: "CPU CFS period to be used for hardcapping (in usecs). 0 to use system default",
6365
},
6466
cli.StringFlag{
6567
Name: "cpu-quota",
66-
Usage: "CPU hardcap limit (in usecs). Allowed cpu time in a given period",
68+
Usage: "CPU CFS hardcap limit (in usecs). Allowed cpu time in a given period",
6769
},
6870
cli.StringFlag{
6971
Name: "cpu-share",
7072
Usage: "CPU shares (relative weight vs. other containers)",
7173
},
74+
cli.StringFlag{
75+
Name: "cpu-rt-period",
76+
Usage: "CPU realtime period to be used for hardcapping (in usecs). 0 to use system default",
77+
},
78+
cli.StringFlag{
79+
Name: "cpu-rt-runtime",
80+
Usage: "CPU realtime hardcap limit (in usecs). Allowed cpu time in a given period",
81+
},
7282
cli.StringFlag{
7383
Name: "cpuset-cpus",
7484
Usage: "CPU(s) to use",
@@ -113,11 +123,13 @@ other options are ignored.
113123
KernelTCP: u64Ptr(0),
114124
},
115125
CPU: &specs.CPU{
116-
Shares: u64Ptr(0),
117-
Quota: u64Ptr(0),
118-
Period: u64Ptr(0),
119-
Cpus: sPtr(""),
120-
Mems: sPtr(""),
126+
Shares: u64Ptr(0),
127+
Quota: u64Ptr(0),
128+
Period: u64Ptr(0),
129+
RealtimeRuntime: u64Ptr(0),
130+
RealtimePeriod: u64Ptr(0),
131+
Cpus: sPtr(""),
132+
Mems: sPtr(""),
121133
},
122134
BlockIO: &specs.BlockIO{
123135
Weight: u16Ptr(0),
@@ -162,6 +174,8 @@ other options are ignored.
162174

163175
{"cpu-period", r.CPU.Period},
164176
{"cpu-quota", r.CPU.Quota},
177+
{"cpu-rt-period", r.CPU.RealtimePeriod},
178+
{"cpu-rt-runtime", r.CPU.RealtimeRuntime},
165179
{"cpu-share", r.CPU.Shares},
166180
} {
167181
if val := context.String(pair.opt); val != "" {
@@ -197,6 +211,8 @@ other options are ignored.
197211
config.Cgroups.Resources.CpuPeriod = int64(*r.CPU.Period)
198212
config.Cgroups.Resources.CpuQuota = int64(*r.CPU.Quota)
199213
config.Cgroups.Resources.CpuShares = int64(*r.CPU.Shares)
214+
config.Cgroups.Resources.CpuRtPeriod = int64(*r.CPU.RealtimePeriod)
215+
config.Cgroups.Resources.CpuRtRuntime = int64(*r.CPU.RealtimeRuntime)
200216
config.Cgroups.Resources.CpusetCpus = *r.CPU.Cpus
201217
config.Cgroups.Resources.CpusetMems = *r.CPU.Mems
202218
config.Cgroups.Resources.KernelMemory = int64(*r.Memory.Kernel)

0 commit comments

Comments
 (0)