Skip to content

Commit 3720db3

Browse files
author
Mrunal Patel
committed
Merge pull request #193 from runcom/blkio-fixes
runtime: config: linux: Edit BlockIO struct
2 parents 8e00c3f + e9d3ac0 commit 3720db3

File tree

2 files changed

+158
-49
lines changed

2 files changed

+158
-49
lines changed

runtime-config-linux.md

Lines changed: 125 additions & 42 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,128 @@ 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-
}
156+
"disableOOMKiller": false
157+
```
158+
159+
#### Memory
160+
161+
```json
162+
"memory": {
163+
"limit": 0,
164+
"reservation": 0,
165+
"swap": 0,
166+
"kernel": 0,
167+
"swappiness": -1
183168
}
184169
```
185170

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.
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+
The following parameters can be specified to setup the block io controller:
191+
192+
* **`blkioWeight`** *(uint16, optional)* - specifies per-cgroup weight. This is default weight of the group on all devices until and unless overridden by per-device rules. The range is from 10 to 1000.
193+
194+
* **`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. The range is from 10 to 1000.
195+
196+
* **`blkioWeightDevice`** *(array, optional)* - specifies the list of devices which will be bandwidth rate limited. The following parameters can be specified per-device:
197+
* **`major, minor`** *(int64, required)* - major, minor numbers for device. More info in `man mknod`.
198+
* **`weight`** *(uint16, optional)* - bandwidth rate for the device, range is from 10 to 1000.
199+
* **`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.
200+
201+
You must specify at least one of `weight` or `leafWeight` in a given entry, and can specify both.
202+
203+
* **`blkioThrottleReadBpsDevice`**, **`blkioThrottleWriteBpsDevice`**, **`blkioThrottleReadIOPSDevice`**, **`blkioThrottleWriteIOPSDevice`** *(array, optional)* - specify the list of devices which will be IO rate limited. The following parameters can be specified per-device:
204+
* **`major, minor`** *(int64, required)* - major, minor numbers for device. More info in `man mknod`.
205+
* **`rate`** *(uint64, required)* - IO rate limit for the device
206+
207+
###### Example
208+
209+
```json
210+
"blockIO": {
211+
"blkioWeight": 0,
212+
"blkioLeafWeight": 0,
213+
"blkioWeightDevice": [
214+
{
215+
"major": 8,
216+
"minor": 0,
217+
"weight": 500,
218+
"leafWeight": 300
219+
},
220+
{
221+
"major": 8,
222+
"minor": 16,
223+
"weight": 500
224+
}
225+
],
226+
"blkioThrottleReadBpsDevice": [
227+
{
228+
"major": 8,
229+
"minor": 0,
230+
"rate": 600
231+
}
232+
],
233+
"blkioThrottleWriteIOPSDevice": [
234+
{
235+
"major": 8,
236+
"minor": 16,
237+
"rate": 300
238+
}
239+
]
240+
}
241+
```
242+
243+
#### Huge page limits
244+
245+
```json
246+
"hugepageLimits": [
247+
{
248+
"pageSize": "2MB",
249+
"limit": 9223372036854771712
250+
}
251+
]
252+
```
253+
254+
#### Network
255+
256+
```json
257+
"network": {
258+
"classId": "ClassId",
259+
"priorities": [
260+
{
261+
"name": "eth0",
262+
"priority": 500
263+
},
264+
{
265+
"name": "eth1",
266+
"priority": 1000
267+
}
268+
]
269+
}
270+
```
188271

189272
## Sysctl
190273

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)