-
Kir Kolyshkin authored
Commit bf382fb0bcef4 ("block: remove legacy IO schedulers", Oct 12 2018) removes the CFQ scheduler, together with blkio.weight and blkio.weight_device described in cgroup v1 documentation. Users are supposed to use the BFQ scheduler, which cgroup file for setting weight is blkio.bfq.weight, but there is no way to set per-device weight. Later, commit 795fe54c per-device weights for BFQ, meaning that blkio.bfq.weight and blkio.bfq.weight_device can be used in a way similar to the old CFQ cgroup interface. Yet, the cgroup v1 docs were never updated. Fix this: - use the new file names; - fix the range for weight (used to be 10..1000, now 1..1000); - link to BFQ scheduler docs. Acked-by:
Tejun Heo <tj@kernel.org> Signed-off-by:
Kir Kolyshkin <kolyshkin@gmail.com> Signed-off-by:
Jens Axboe <axboe@kernel.dk>
82861595
Block IO Controller
Overview
cgroup subsys "blkio" implements the block io controller. There seems to be a need of various kinds of IO control policies (like proportional BW, max BW) both at leaf nodes as well as at intermediate nodes in a storage hierarchy. Plan is to use the same cgroup based management interface for blkio controller and based on user options switch IO policies in the background.
One IO control policy is throttling policy which can be used to specify upper IO rate limits on devices. This policy is implemented in generic block layer and can be used on leaf nodes as well as higher level logical devices like device mapper.
HOWTO
Throttling/Upper Limit policy
Enable Block IO controller:
CONFIG_BLK_CGROUP=y
Enable throttling in block layer:
CONFIG_BLK_DEV_THROTTLING=y
Mount blkio controller (see cgroups.txt, Why are cgroups needed?):
mount -t cgroup -o blkio none /sys/fs/cgroup/blkio
Specify a bandwidth rate on particular device for root group. The format for policy is "<major>:<minor> <bytes_per_second>":
echo "8:16 1048576" > /sys/fs/cgroup/blkio/blkio.throttle.read_bps_device
This will put a limit of 1MB/second on reads happening for root group on device having major/minor number 8:16.
Run dd to read a file and see if rate is throttled to 1MB/s or not:
# dd iflag=direct if=/mnt/common/zerofile of=/dev/null bs=4K count=1024
1024+0 records in
1024+0 records out
4194304 bytes (4.2 MB) copied, 4.0001 s, 1.0 MB/s
Limits for writes can be put using blkio.throttle.write_bps_device file.