Skip to content

Commit 3c64554

Browse files
committed
runtime: config: linux: Edit BlockIO struct
`WeightDevice`, `ThrottleReadBpsDevice`, `ThrottleWriteBpsDevice`, `ThrottleReadIOpsDevice`, `ThrottleWriteIOpsDevice` are now slices to well defined structs to allow setting multiple devices in their respective blkio file. By using a string to represents those values it wasn't possible to set correct values when multiple devices were passed in the config (either newline separated or comma separated). Signed-off-by: Antonio Murdaca <runcom@linux.com>
1 parent 7a05004 commit 3c64554

2 files changed

Lines changed: 78 additions & 42 deletions

File tree

runtime-config-linux.md

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -146,45 +146,55 @@ The cgroups will be created if they don't exist.
146146

147147
`cgroupsPath` can be used to either control the cgroups hierarchy for containers or to run a new process in an existing container.
148148

149-
Optionally, cgroups limits can be specified via `resources`.
149+
You can configure a container's cgroups via the `resources` field of the Linux configuration.
150+
Do not specify `resources` unless limits have to be updated.
151+
For example, to run a new process in an existing container without updating limits, `resources` need not be specified.
152+
153+
### Block IO Controller
150154

151155
```json
152-
"resources": {
153-
"disableOOMKiller": false,
154-
"memory": {
155-
"limit": 0,
156-
"reservation": 0,
157-
"swap": 0,
158-
"kernel": 0,
159-
"swappiness": -1
160-
},
161-
"cpu": {
162-
"shares": 0,
163-
"quota": 0,
164-
"period": 0,
165-
"realtimeRuntime": 0,
166-
"realtimePeriod": 0,
167-
"cpus": "",
168-
"mems": ""
169-
},
170-
"blockIO": {
171-
"blkioWeight": 0,
172-
"blkioWeightDevice": "",
173-
"blkioThrottleReadBpsDevice": "",
174-
"blkioThrottleWriteBpsDevice": "",
175-
"blkioThrottleReadIopsDevice": "",
176-
"blkioThrottleWriteIopsDevice": ""
177-
},
178-
"hugepageLimits": null,
179-
"network": {
180-
"classId": "",
181-
"priorities": null
182-
}
183-
}
156+
"blockIO": {
157+
"blkioWeight": 0,
158+
"blkioLeafWeight": 0,
159+
"blkioWeightDevice": [
160+
{
161+
"major": 8,
162+
"minor": 0,
163+
"weight": 500,
164+
"leafWeight": 300
165+
},
166+
{
167+
"major": 8,
168+
"minor": 16,
169+
"weight": 500
170+
}
171+
],
172+
"blkioThrottleReadBpsDevice": [
173+
{
174+
"major": 8,
175+
"minor": 0,
176+
"rate": 600
177+
}
178+
],
179+
"blkioThrottleWriteBpsDevice": null,
180+
"blkioThrottleReadIopsDevice": null,
181+
"blkioThrottleWriteIopsDevice": [
182+
{
183+
"major": 8,
184+
"minor": 16,
185+
"rate": 300
186+
}
187+
]
188+
}
184189
```
185190

186-
Do not specify `resources` unless limits have to be updated.
187-
For example, to run a new process in an existing container without updating limits, `resources` need not be specified.
191+
* **blkioWeight** .
192+
* **blkioLeafWeight** .
193+
* **blkioWeightDevice** .
194+
* **blkioThrottleReadBpsDevice** .
195+
* **blkioThrottleWriteBpsDevice** .
196+
* **blkioThrottleReadIopsDevice** .
197+
* **blkioThrottleWriteIopsDevice** .
188198

189199
## Sysctl
190200

runtime_config_linux.go

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,46 @@ type InterfacePriority struct {
104104
Priority int64 `json:"priority"`
105105
}
106106

107+
// blockIODevice holds major:minor format supported in blkio cgroup
108+
type blockIODevice struct {
109+
// Major is the device's major number.
110+
Major int64 `json:"major"`
111+
// Minor is the device's minor number.
112+
Minor int64 `json:"minor"`
113+
}
114+
115+
// WeightDevice struct holds a `major:minor weight` pair for blkioWeightDevice
116+
type WeightDevice struct {
117+
blockIODevice
118+
// Weight is the bandwidth rate for the device, range is from 10 to 1000
119+
Weight uint16 `json:"weight"`
120+
// LeafWeight is the bandwidth rate given to the device while competing with the cgroup's child cgroups, range is from 10 to 1000, cfq scheduler only
121+
LeafWeight uint16 `json:"leafWeight"`
122+
}
123+
124+
// ThrottleDevice struct holds a `major:minor rate_per_second` pair
125+
type ThrottleDevice struct {
126+
blockIODevice
127+
// Rate is the IO rate limit per cgroup per device
128+
Rate uint64 `json:"rate"`
129+
}
130+
107131
// BlockIO for Linux cgroup 'blkio' resource management
108132
type BlockIO struct {
109133
// Specifies per cgroup weight, range is from 10 to 1000
110-
Weight int64 `json:"blkioWeight"`
134+
Weight uint16 `json:"blkioWeight"`
135+
// Specifies tasks' weight in the given cgroup while competing with the cgroup's child cgroups, range is from 10 to 1000, cfq scheduler only
136+
LeafWeight uint16 `json:"blkioLeafWeight"`
111137
// Weight per cgroup per device, can override BlkioWeight
112-
WeightDevice string `json:"blkioWeightDevice"`
138+
WeightDevice []*WeightDevice `json:"blkioWeightDevice"`
113139
// IO read rate limit per cgroup per device, bytes per second
114-
ThrottleReadBpsDevice string `json:"blkioThrottleReadBpsDevice"`
115-
// IO write rate limit per cgroup per divice, bytes per second
116-
ThrottleWriteBpsDevice string `json:"blkioThrottleWriteBpsDevice"`
140+
ThrottleReadBpsDevice []*ThrottleDevice `json:"blkioThrottleReadBpsDevice"`
141+
// IO write rate limit per cgroup per device, bytes per second
142+
ThrottleWriteBpsDevice []*ThrottleDevice `json:"blkioThrottleWriteBpsDevice"`
117143
// IO read rate limit per cgroup per device, IO per second
118-
ThrottleReadIOpsDevice string `json:"blkioThrottleReadIopsDevice"`
144+
ThrottleReadIOpsDevice []*ThrottleDevice `json:"blkioThrottleReadIopsDevice"`
119145
// IO write rate limit per cgroup per device, IO per second
120-
ThrottleWriteIOpsDevice string `json:"blkioThrottleWriteIopsDevice"`
146+
ThrottleWriteIOpsDevice []*ThrottleDevice `json:"blkioThrottleWriteIopsDevice"`
121147
}
122148

123149
// Memory for Linux cgroup 'memory' resource management

0 commit comments

Comments
 (0)