@@ -17,36 +17,37 @@ level logical devices like device mapper.
17
17
18
18
HOWTO
19
19
=====
20
+
20
21
Throttling/Upper Limit policy
21
22
-----------------------------
22
- - Enable Block IO controller::
23
+ Enable Block IO controller::
23
24
24
25
CONFIG_BLK_CGROUP=y
25
26
26
- - Enable throttling in block layer::
27
+ Enable throttling in block layer::
27
28
28
29
CONFIG_BLK_DEV_THROTTLING=y
29
30
30
- - Mount blkio controller (see cgroups.txt, Why are cgroups needed?)::
31
+ Mount blkio controller (see cgroups.txt, Why are cgroups needed?)::
31
32
32
33
mount -t cgroup -o blkio none /sys/fs/cgroup/blkio
33
34
34
- - Specify a bandwidth rate on particular device for root group. The format
35
- for policy is "<major>:<minor> <bytes_per_second>"::
35
+ Specify a bandwidth rate on particular device for root group. The format
36
+ for policy is "<major>:<minor> <bytes_per_second>"::
36
37
37
38
echo "8:16 1048576" > /sys/fs/cgroup/blkio/blkio.throttle.read_bps_device
38
39
39
- Above will put a limit of 1MB/second on reads happening for root group
40
- on device having major/minor number 8:16.
40
+ This will put a limit of 1MB/second on reads happening for root group
41
+ on device having major/minor number 8:16.
41
42
42
- - Run dd to read a file and see if rate is throttled to 1MB/s or not::
43
+ Run dd to read a file and see if rate is throttled to 1MB/s or not::
43
44
44
45
# dd iflag=direct if=/mnt/common/zerofile of=/dev/null bs=4K count=1024
45
46
1024+0 records in
46
47
1024+0 records out
47
48
4194304 bytes (4.2 MB) copied, 4.0001 s, 1.0 MB/s
48
49
49
- Limits for writes can be put using blkio.throttle.write_bps_device file.
50
+ Limits for writes can be put using blkio.throttle.write_bps_device file.
50
51
51
52
Hierarchical Cgroups
52
53
====================
@@ -79,85 +80,89 @@ following::
79
80
80
81
Various user visible config options
81
82
===================================
82
- CONFIG_BLK_CGROUP
83
- - Block IO controller.
84
83
85
- CONFIG_BFQ_CGROUP_DEBUG
86
- - Debug help. Right now some additional stats file show up in cgroup
84
+ CONFIG_BLK_CGROUP
85
+ Block IO controller.
86
+
87
+ CONFIG_BFQ_CGROUP_DEBUG
88
+ Debug help. Right now some additional stats file show up in cgroup
87
89
if this option is enabled.
88
90
89
- CONFIG_BLK_DEV_THROTTLING
90
- - Enable block device throttling support in block layer.
91
+ CONFIG_BLK_DEV_THROTTLING
92
+ Enable block device throttling support in block layer.
91
93
92
94
Details of cgroup files
93
95
=======================
96
+
94
97
Proportional weight policy files
95
98
--------------------------------
96
- - blkio.weight
97
- - Specifies per cgroup weight. This is default weight of the group
98
- on all the devices until and unless overridden by per device rule.
99
- (See blkio.weight_device).
100
- Currently allowed range of weights is from 10 to 1000.
101
99
102
- - blkio.weight_device
103
- - One can specify per cgroup per device rules using this interface.
104
- These rules override the default value of group weight as specified
105
- by blkio.weight.
100
+ blkio.bfq.weight
101
+ Specifies per cgroup weight. This is default weight of the group
102
+ on all the devices until and unless overridden by per device rule
103
+ (see `blkio.bfq.weight_device ` below).
104
+
105
+ Currently allowed range of weights is from 1 to 1000. For more details,
106
+ see Documentation/block/bfq-iosched.rst.
107
+
108
+ blkio.bfq.weight_device
109
+ Specifes per cgroup per device weights, overriding the default group
110
+ weight. For more details, see Documentation/block/bfq-iosched.rst.
106
111
107
112
Following is the format::
108
113
109
- # echo dev_maj:dev_minor weight > blkio.weight_device
114
+ # echo dev_maj:dev_minor weight > blkio.bfq. weight_device
110
115
111
116
Configure weight=300 on /dev/sdb (8:16) in this cgroup::
112
117
113
- # echo 8:16 300 > blkio.weight_device
114
- # cat blkio.weight_device
118
+ # echo 8:16 300 > blkio.bfq. weight_device
119
+ # cat blkio.bfq. weight_device
115
120
dev weight
116
121
8:16 300
117
122
118
123
Configure weight=500 on /dev/sda (8:0) in this cgroup::
119
124
120
- # echo 8:0 500 > blkio.weight_device
121
- # cat blkio.weight_device
125
+ # echo 8:0 500 > blkio.bfq. weight_device
126
+ # cat blkio.bfq. weight_device
122
127
dev weight
123
128
8:0 500
124
129
8:16 300
125
130
126
131
Remove specific weight for /dev/sda in this cgroup::
127
132
128
- # echo 8:0 0 > blkio.weight_device
129
- # cat blkio.weight_device
133
+ # echo 8:0 0 > blkio.bfq. weight_device
134
+ # cat blkio.bfq. weight_device
130
135
dev weight
131
136
8:16 300
132
137
133
- - blkio.time
134
- - disk time allocated to cgroup per device in milliseconds. First
138
+ blkio.time
139
+ Disk time allocated to cgroup per device in milliseconds. First
135
140
two fields specify the major and minor number of the device and
136
141
third field specifies the disk time allocated to group in
137
142
milliseconds.
138
143
139
- - blkio.sectors
140
- - number of sectors transferred to/from disk by the group. First
144
+ blkio.sectors
145
+ Number of sectors transferred to/from disk by the group. First
141
146
two fields specify the major and minor number of the device and
142
147
third field specifies the number of sectors transferred by the
143
148
group to/from the device.
144
149
145
- - blkio.io_service_bytes
146
- - Number of bytes transferred to/from the disk by the group. These
150
+ blkio.io_service_bytes
151
+ Number of bytes transferred to/from the disk by the group. These
147
152
are further divided by the type of operation - read or write, sync
148
153
or async. First two fields specify the major and minor number of the
149
154
device, third field specifies the operation type and the fourth field
150
155
specifies the number of bytes.
151
156
152
- - blkio.io_serviced
153
- - Number of IOs (bio) issued to the disk by the group. These
157
+ blkio.io_serviced
158
+ Number of IOs (bio) issued to the disk by the group. These
154
159
are further divided by the type of operation - read or write, sync
155
160
or async. First two fields specify the major and minor number of the
156
161
device, third field specifies the operation type and the fourth field
157
162
specifies the number of IOs.
158
163
159
- - blkio.io_service_time
160
- - Total amount of time between request dispatch and request completion
164
+ blkio.io_service_time
165
+ Total amount of time between request dispatch and request completion
161
166
for the IOs done by this cgroup. This is in nanoseconds to make it
162
167
meaningful for flash devices too. For devices with queue depth of 1,
163
168
this time represents the actual service time. When queue_depth > 1,
@@ -170,8 +175,8 @@ Proportional weight policy files
170
175
specifies the operation type and the fourth field specifies the
171
176
io_service_time in ns.
172
177
173
- - blkio.io_wait_time
174
- - Total amount of time the IOs for this cgroup spent waiting in the
178
+ blkio.io_wait_time
179
+ Total amount of time the IOs for this cgroup spent waiting in the
175
180
scheduler queues for service. This can be greater than the total time
176
181
elapsed since it is cumulative io_wait_time for all IOs. It is not a
177
182
measure of total time the cgroup spent waiting but rather a measure of
@@ -185,24 +190,24 @@ Proportional weight policy files
185
190
minor number of the device, third field specifies the operation type
186
191
and the fourth field specifies the io_wait_time in ns.
187
192
188
- - blkio.io_merged
189
- - Total number of bios/requests merged into requests belonging to this
193
+ blkio.io_merged
194
+ Total number of bios/requests merged into requests belonging to this
190
195
cgroup. This is further divided by the type of operation - read or
191
196
write, sync or async.
192
197
193
- - blkio.io_queued
194
- - Total number of requests queued up at any given instant for this
198
+ blkio.io_queued
199
+ Total number of requests queued up at any given instant for this
195
200
cgroup. This is further divided by the type of operation - read or
196
201
write, sync or async.
197
202
198
- - blkio.avg_queue_size
199
- - Debugging aid only enabled if CONFIG_BFQ_CGROUP_DEBUG=y.
203
+ blkio.avg_queue_size
204
+ Debugging aid only enabled if CONFIG_BFQ_CGROUP_DEBUG=y.
200
205
The average queue size for this cgroup over the entire time of this
201
206
cgroup's existence. Queue size samples are taken each time one of the
202
207
queues of this cgroup gets a timeslice.
203
208
204
- - blkio.group_wait_time
205
- - Debugging aid only enabled if CONFIG_BFQ_CGROUP_DEBUG=y.
209
+ blkio.group_wait_time
210
+ Debugging aid only enabled if CONFIG_BFQ_CGROUP_DEBUG=y.
206
211
This is the amount of time the cgroup had to wait since it became busy
207
212
(i.e., went from 0 to 1 request queued) to get a timeslice for one of
208
213
its queues. This is different from the io_wait_time which is the
@@ -212,85 +217,85 @@ Proportional weight policy files
212
217
will only report the group_wait_time accumulated till the last time it
213
218
got a timeslice and will not include the current delta.
214
219
215
- - blkio.empty_time
216
- - Debugging aid only enabled if CONFIG_BFQ_CGROUP_DEBUG=y.
220
+ blkio.empty_time
221
+ Debugging aid only enabled if CONFIG_BFQ_CGROUP_DEBUG=y.
217
222
This is the amount of time a cgroup spends without any pending
218
223
requests when not being served, i.e., it does not include any time
219
224
spent idling for one of the queues of the cgroup. This is in
220
225
nanoseconds. If this is read when the cgroup is in an empty state,
221
226
the stat will only report the empty_time accumulated till the last
222
227
time it had a pending request and will not include the current delta.
223
228
224
- - blkio.idle_time
225
- - Debugging aid only enabled if CONFIG_BFQ_CGROUP_DEBUG=y.
229
+ blkio.idle_time
230
+ Debugging aid only enabled if CONFIG_BFQ_CGROUP_DEBUG=y.
226
231
This is the amount of time spent by the IO scheduler idling for a
227
232
given cgroup in anticipation of a better request than the existing ones
228
233
from other queues/cgroups. This is in nanoseconds. If this is read
229
234
when the cgroup is in an idling state, the stat will only report the
230
235
idle_time accumulated till the last idle period and will not include
231
236
the current delta.
232
237
233
- - blkio.dequeue
234
- - Debugging aid only enabled if CONFIG_BFQ_CGROUP_DEBUG=y. This
238
+ blkio.dequeue
239
+ Debugging aid only enabled if CONFIG_BFQ_CGROUP_DEBUG=y. This
235
240
gives the statistics about how many a times a group was dequeued
236
241
from service tree of the device. First two fields specify the major
237
242
and minor number of the device and third field specifies the number
238
243
of times a group was dequeued from a particular device.
239
244
240
- - blkio.*_recursive
241
- - Recursive version of various stats. These files show the
245
+ blkio.*_recursive
246
+ Recursive version of various stats. These files show the
242
247
same information as their non-recursive counterparts but
243
248
include stats from all the descendant cgroups.
244
249
245
250
Throttling/Upper limit policy files
246
251
-----------------------------------
247
- - blkio.throttle.read_bps_device
248
- - Specifies upper limit on READ rate from the device. IO rate is
252
+ blkio.throttle.read_bps_device
253
+ Specifies upper limit on READ rate from the device. IO rate is
249
254
specified in bytes per second. Rules are per device. Following is
250
255
the format::
251
256
252
257
echo "<major>:<minor> <rate_bytes_per_second>" > /cgrp/blkio.throttle.read_bps_device
253
258
254
- - blkio.throttle.write_bps_device
255
- - Specifies upper limit on WRITE rate to the device. IO rate is
259
+ blkio.throttle.write_bps_device
260
+ Specifies upper limit on WRITE rate to the device. IO rate is
256
261
specified in bytes per second. Rules are per device. Following is
257
262
the format::
258
263
259
264
echo "<major>:<minor> <rate_bytes_per_second>" > /cgrp/blkio.throttle.write_bps_device
260
265
261
- - blkio.throttle.read_iops_device
262
- - Specifies upper limit on READ rate from the device. IO rate is
266
+ blkio.throttle.read_iops_device
267
+ Specifies upper limit on READ rate from the device. IO rate is
263
268
specified in IO per second. Rules are per device. Following is
264
269
the format::
265
270
266
271
echo "<major>:<minor> <rate_io_per_second>" > /cgrp/blkio.throttle.read_iops_device
267
272
268
- - blkio.throttle.write_iops_device
269
- - Specifies upper limit on WRITE rate to the device. IO rate is
273
+ blkio.throttle.write_iops_device
274
+ Specifies upper limit on WRITE rate to the device. IO rate is
270
275
specified in io per second. Rules are per device. Following is
271
276
the format::
272
277
273
278
echo "<major>:<minor> <rate_io_per_second>" > /cgrp/blkio.throttle.write_iops_device
274
279
275
- Note: If both BW and IOPS rules are specified for a device, then IO is
276
- subjected to both the constraints.
280
+ Note: If both BW and IOPS rules are specified for a device, then IO is
281
+ subjected to both the constraints.
277
282
278
- - blkio.throttle.io_serviced
279
- - Number of IOs (bio) issued to the disk by the group. These
283
+ blkio.throttle.io_serviced
284
+ Number of IOs (bio) issued to the disk by the group. These
280
285
are further divided by the type of operation - read or write, sync
281
286
or async. First two fields specify the major and minor number of the
282
287
device, third field specifies the operation type and the fourth field
283
288
specifies the number of IOs.
284
289
285
- - blkio.throttle.io_service_bytes
286
- - Number of bytes transferred to/from the disk by the group. These
290
+ blkio.throttle.io_service_bytes
291
+ Number of bytes transferred to/from the disk by the group. These
287
292
are further divided by the type of operation - read or write, sync
288
293
or async. First two fields specify the major and minor number of the
289
294
device, third field specifies the operation type and the fourth field
290
295
specifies the number of bytes.
291
296
292
297
Common files among various policies
293
298
-----------------------------------
294
- - blkio.reset_stats
295
- - Writing an int to this file will result in resetting all the stats
299
+ blkio.reset_stats
300
+ Writing an int to this file will result in resetting all the stats
296
301
for that cgroup.
0 commit comments