Skip to content

Commit 7561a4a

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 7561a4a

2 files changed

Lines changed: 161 additions & 50 deletions

File tree

runtime-config-linux.md

Lines changed: 128 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ within the container.
5050
Devices is an array specifying the list of devices to be created in the container.
5151
Next parameters can be specified:
5252

53-
* type - type of device: 'c', 'b', 'u' or 'p'. More info in `man mknod`
54-
* path - full path to device inside container
55-
* major, minor - major, minor numbers for device. More info in `man mknod`.
53+
* **type** - type of device: `c`, `b`, `u` or `p`. More info in `man mknod`
54+
* **path** - full path to device inside container
55+
* **major, minor** - major, minor numbers for device. More info in `man mknod`.
5656
There is special value: `-1`, which means `*` for `device`
5757
cgroup setup.
58-
* permissions - cgroup permissions for device. A composition of 'r'
59-
(read), 'w' (write), and 'm' (mknod).
60-
* fileMode - file mode for device file
61-
* uid - uid of device owner
62-
* gid - gid of device owner
58+
* **permissions** - cgroup permissions for device. A composition of `r`
59+
(read), `w` (write), and `m` (mknod).
60+
* **fileMode** - file mode for device file
61+
* **uid** - uid of device owner
62+
* **gid** - gid of device owner
6363

6464
```json
6565
"devices": [
@@ -146,45 +146,130 @@ 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+
#### Disable out-of-memory killer
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+
"disableOOMKiller": false
184157
```
185158

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.
159+
#### Memory
160+
161+
```json
162+
"memory": {
163+
"limit": 0,
164+
"reservation": 0,
165+
"swap": 0,
166+
"kernel": 0,
167+
"swappiness": -1
168+
}
169+
```
170+
171+
#### CPU
172+
173+
```json
174+
"cpu": {
175+
"shares": 0,
176+
"quota": 0,
177+
"period": 0,
178+
"realtimeRuntime": 0,
179+
"realtimePeriod": 0,
180+
"cpus": "",
181+
"mems": ""
182+
}
183+
```
184+
185+
#### Block IO Controller
186+
187+
`blockIO` represents the cgroup subsystem `blkio` which implements the block io controller.
188+
For more information, see the [kernel cgroups documentation about `blkio`](https://www.kernel.org/doc/Documentation/cgroups/blkio-controller.txt).
189+
190+
```json
191+
"blockIO": {
192+
"blkioWeight": 0,
193+
"blkioLeafWeight": 0,
194+
"blkioWeightDevice": [
195+
{
196+
"major": 8,
197+
"minor": 0,
198+
"weight": 500,
199+
"leafWeight": 300
200+
},
201+
{
202+
"major": 8,
203+
"minor": 16,
204+
"weight": 500
205+
}
206+
],
207+
"blkioThrottleReadBpsDevice": [
208+
{
209+
"major": 8,
210+
"minor": 0,
211+
"rate": 600
212+
}
213+
],
214+
"blkioThrottleWriteBpsDevice": null,
215+
"blkioThrottleReadIOPSDevice": null,
216+
"blkioThrottleWriteIOPSDevice": [
217+
{
218+
"major": 8,
219+
"minor": 16,
220+
"rate": 300
221+
}
222+
]
223+
}
224+
```
225+
226+
`blkioWeight` (uint16, optional) - specifies per cgroup weight, this is default weight of the group on all the devices until and unless overridden by per device rule, range is from 10 to 1000
227+
228+
`blkioLeafWeight` (uint16, optional) - equivalents of `blkioWeight` for the purpose of deciding how much weight tasks in the given cgroup has while competing with the cgroup's child cgroups, range is from 10 to 1000
229+
230+
`blkioWeightDevice` (array, optional) - specifies the list of devices on which bandwidth rate limit will be applied. Next parameters can be specified per device:
231+
232+
* **major** (int64, required) - major number of the device that will be limited
233+
* **minor** (int64, required) - minor number of the device that will be limited
234+
* **weight** (uint16, optional) - bandwidth rate for the device, range is from 10 to 1000
235+
* **leafWeight** (uint16, optional) - bandwidth rate for the device while competing with the cgroup's child cgroups, range is from 10 to 1000, cfq scheduler only
236+
237+
You must specify at least one of `weight` or `leafWeight` in a given entry, and can specify both.
238+
239+
`blkioThrottleReadBpsDevice`, `blkioThrottleWriteBpsDevice`, `blkioThrottleReadIOPSDevice`, `blkioThrottleWriteIOPSDevice` (array, optional) - specify the list of devices on which IO rate limit will be applied. Next parameters can be specified per device:
240+
241+
* **major** (int64, required) - major number of the device that will be limited
242+
* **minor** (int64, required) - minor number of the device that will be limited
243+
* **rate** (uint64, required) - IO rate limit for the device
244+
245+
#### Huge page limits
246+
247+
```json
248+
"hugepageLimits": [
249+
{
250+
"pageSize": "2MB",
251+
"limit": 9223372036854771712
252+
}
253+
]
254+
```
255+
256+
#### Network
257+
258+
```json
259+
"network": {
260+
"classId": "ClassId",
261+
"priorities": [
262+
{
263+
"name": "eth0",
264+
"priority": 500
265+
},
266+
{
267+
"name": "eth1",
268+
"priority": 1000
269+
}
270+
]
271+
}
272+
```
188273

189274
## Sysctl
190275

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 for 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)