Skip to content

Commit e9dd2b6

Browse files
committed
Merge branch 'for-2.6.37/core' of git://git.kernel.dk/linux-2.6-block
* 'for-2.6.37/core' of git://git.kernel.dk/linux-2.6-block: (39 commits) cfq-iosched: Fix a gcc 4.5 warning and put some comments block: Turn bvec_k{un,}map_irq() into static inline functions block: fix accounting bug on cross partition merges block: Make the integrity mapped property a bio flag block: Fix double free in blk_integrity_unregister block: Ensure physical block size is unsigned int blkio-throttle: Fix possible multiplication overflow in iops calculations blkio-throttle: limit max iops value to UINT_MAX blkio-throttle: There is no need to convert jiffies to milli seconds blkio-throttle: Fix link failure failure on i386 blkio: Recalculate the throttled bio dispatch time upon throttle limit change blkio: Add root group to td->tg_list blkio: deletion of a cgroup was causes oops blkio: Do not export throttle files if CONFIG_BLK_DEV_THROTTLING=n block: set the bounce_pfn to the actual DMA limit rather than to max memory block: revert bad fix for memory hotplug causing bounces Fix compile error in blk-exec.c for !CONFIG_DETECT_HUNG_TASK block: set the bounce_pfn to the actual DMA limit rather than to max memory block: Prevent hang_check firing during long I/O cfq: improve fsync performance for small files ... Fix up trivial conflicts due to __rcu sparse annotation in include/linux/genhd.h
2 parents 4f3a29d + b462732 commit e9dd2b6

43 files changed

Lines changed: 2494 additions & 299 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/cgroups/blkio-controller.txt‎

Lines changed: 103 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ both at leaf nodes as well as at intermediate nodes in a storage hierarchy.
88
Plan is to use the same cgroup based management interface for blkio controller
99
and based on user options switch IO policies in the background.
1010

11-
In the first phase, this patchset implements proportional weight time based
12-
division of disk policy. It is implemented in CFQ. Hence this policy takes
13-
effect only on leaf nodes when CFQ is being used.
11+
Currently two IO control policies are implemented. First one is proportional
12+
weight time based division of disk policy. It is implemented in CFQ. Hence
13+
this policy takes effect only on leaf nodes when CFQ is being used. The second
14+
one is throttling policy which can be used to specify upper IO rate limits
15+
on devices. This policy is implemented in generic block layer and can be
16+
used on leaf nodes as well as higher level logical devices like device mapper.
1417

1518
HOWTO
1619
=====
20+
Proportional Weight division of bandwidth
21+
-----------------------------------------
1722
You can do a very simple testing of running two dd threads in two different
1823
cgroups. Here is what you can do.
1924

@@ -55,6 +60,35 @@ cgroups. Here is what you can do.
5560
group dispatched to the disk. We provide fairness in terms of disk time, so
5661
ideally io.disk_time of cgroups should be in proportion to the weight.
5762

63+
Throttling/Upper Limit policy
64+
-----------------------------
65+
- Enable Block IO controller
66+
CONFIG_BLK_CGROUP=y
67+
68+
- Enable throttling in block layer
69+
CONFIG_BLK_DEV_THROTTLING=y
70+
71+
- Mount blkio controller
72+
mount -t cgroup -o blkio none /cgroup/blkio
73+
74+
- Specify a bandwidth rate on particular device for root group. The format
75+
for policy is "<major>:<minor> <byes_per_second>".
76+
77+
echo "8:16 1048576" > /cgroup/blkio/blkio.read_bps_device
78+
79+
Above will put a limit of 1MB/second on reads happening for root group
80+
on device having major/minor number 8:16.
81+
82+
- Run dd to read a file and see if rate is throttled to 1MB/s or not.
83+
84+
# dd if=/mnt/common/zerofile of=/dev/null bs=4K count=1024
85+
# iflag=direct
86+
1024+0 records in
87+
1024+0 records out
88+
4194304 bytes (4.2 MB) copied, 4.0001 s, 1.0 MB/s
89+
90+
Limits for writes can be put using blkio.write_bps_device file.
91+
5892
Various user visible config options
5993
===================================
6094
CONFIG_BLK_CGROUP
@@ -68,8 +102,13 @@ CONFIG_CFQ_GROUP_IOSCHED
68102
- Enables group scheduling in CFQ. Currently only 1 level of group
69103
creation is allowed.
70104

105+
CONFIG_BLK_DEV_THROTTLING
106+
- Enable block device throttling support in block layer.
107+
71108
Details of cgroup files
72109
=======================
110+
Proportional weight policy files
111+
--------------------------------
73112
- blkio.weight
74113
- Specifies per cgroup weight. This is default weight of the group
75114
on all the devices until and unless overridden by per device rule.
@@ -210,6 +249,67 @@ Details of cgroup files
210249
and minor number of the device and third field specifies the number
211250
of times a group was dequeued from a particular device.
212251

252+
Throttling/Upper limit policy files
253+
-----------------------------------
254+
- blkio.throttle.read_bps_device
255+
- Specifies upper limit on READ rate from the device. IO rate is
256+
specified in bytes per second. Rules are per deivce. Following is
257+
the format.
258+
259+
echo "<major>:<minor> <rate_bytes_per_second>" > /cgrp/blkio.read_bps_device
260+
261+
- blkio.throttle.write_bps_device
262+
- Specifies upper limit on WRITE rate to the device. IO rate is
263+
specified in bytes per second. Rules are per deivce. Following is
264+
the format.
265+
266+
echo "<major>:<minor> <rate_bytes_per_second>" > /cgrp/blkio.write_bps_device
267+
268+
- blkio.throttle.read_iops_device
269+
- Specifies upper limit on READ rate from the device. IO rate is
270+
specified in IO per second. Rules are per deivce. Following is
271+
the format.
272+
273+
echo "<major>:<minor> <rate_io_per_second>" > /cgrp/blkio.read_iops_device
274+
275+
- blkio.throttle.write_iops_device
276+
- Specifies upper limit on WRITE rate to the device. IO rate is
277+
specified in io per second. Rules are per deivce. Following is
278+
the format.
279+
280+
echo "<major>:<minor> <rate_io_per_second>" > /cgrp/blkio.write_iops_device
281+
282+
Note: If both BW and IOPS rules are specified for a device, then IO is
283+
subjectd to both the constraints.
284+
285+
- blkio.throttle.io_serviced
286+
- Number of IOs (bio) completed to/from the disk by the group (as
287+
seen by throttling policy). These are further divided by the type
288+
of operation - read or write, sync or async. First two fields specify
289+
the major and minor number of the device, third field specifies the
290+
operation type and the fourth field specifies the number of IOs.
291+
292+
blkio.io_serviced does accounting as seen by CFQ and counts are in
293+
number of requests (struct request). On the other hand,
294+
blkio.throttle.io_serviced counts number of IO in terms of number
295+
of bios as seen by throttling policy. These bios can later be
296+
merged by elevator and total number of requests completed can be
297+
lesser.
298+
299+
- blkio.throttle.io_service_bytes
300+
- Number of bytes transferred to/from the disk by the group. These
301+
are further divided by the type of operation - read or write, sync
302+
or async. First two fields specify the major and minor number of the
303+
device, third field specifies the operation type and the fourth field
304+
specifies the number of bytes.
305+
306+
These numbers should roughly be same as blkio.io_service_bytes as
307+
updated by CFQ. The difference between two is that
308+
blkio.io_service_bytes will not be updated if CFQ is not operating
309+
on request queue.
310+
311+
Common files among various policies
312+
-----------------------------------
213313
- blkio.reset_stats
214314
- Writing an int to this file will result in resetting all the stats
215315
for that cgroup.

‎block/Kconfig‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ config BLK_DEV_INTEGRITY
7777
T10/SCSI Data Integrity Field or the T13/ATA External Path
7878
Protection. If in doubt, say N.
7979

80+
config BLK_DEV_THROTTLING
81+
bool "Block layer bio throttling support"
82+
depends on BLK_CGROUP=y && EXPERIMENTAL
83+
default n
84+
---help---
85+
Block layer bio throttling support. It can be used to limit
86+
the IO rate to a device. IO rate policies are per cgroup and
87+
one needs to mount and use blkio cgroup controller for creating
88+
cgroups and specifying per device IO rate policies.
89+
90+
See Documentation/cgroups/blkio-controller.txt for more information.
91+
8092
endif # BLOCK
8193

8294
config BLOCK_COMPAT

‎block/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ obj-$(CONFIG_BLOCK) := elevator.o blk-core.o blk-tag.o blk-sysfs.o \
99

1010
obj-$(CONFIG_BLK_DEV_BSG) += bsg.o
1111
obj-$(CONFIG_BLK_CGROUP) += blk-cgroup.o
12+
obj-$(CONFIG_BLK_DEV_THROTTLING) += blk-throttle.o
1213
obj-$(CONFIG_IOSCHED_NOOP) += noop-iosched.o
1314
obj-$(CONFIG_IOSCHED_DEADLINE) += deadline-iosched.o
1415
obj-$(CONFIG_IOSCHED_CFQ) += cfq-iosched.o

0 commit comments

Comments
 (0)