大网数据广告活动
服务器运维问答

I can't get the cgroup blkio to throttle the iops of processes in a sub-cgroup

· 52CE 我爱测

I can't get the cgroup blkio to throttle the iops of processes in a sub-cgroup. I am using CentOS 7, 3.10.0-229. I create the cgroup /sys/fs/cgroup/blkio/user.slice/test1 and do echo 8:32 10 > /sys/fs/cgroup/blkio/user.slice/test…

问题原文

原帖链接 · Jeff Kubina · CC BY-SA 3.0

I can't get the cgroup blkio to throttle the iops of processes in a sub-cgroup. I am using CentOS 7, 3.10.0-229. I create the cgroup /sys/fs/cgroup/blkio/user.slice/test1 and do

echo 8:32 10 > /sys/fs/cgroup/blkio/user.slice/test1/blkio.throttle.read_iops_device

and likewise for write_iops_device. 8:32 corresponds to HDD at /dev/sdc. I then use stress-ng to read and write to the drive at /srv/hdd-c using

cgexec -g blkio:user.slice/test1 stress-ng --temp-path /srv/hdd-c --hdd 15 -t 180

and

cgexec -g blkio:user.slice/test1 stress-ng --temp-path /srv/hdd-c --readahead 15 -t 180

I confirmed that the 30 processes launched are running in the blkio:user.slice/test1 cgroup using ps eo pid,user,args,cgroup.

When I do iostat 5 the number of tps for sdc is 400 to 600, which is the same as when I run them outside the test1 cgroup. I get the same result if I do echo 8:32 10 > /sys/fs/cgroup/blkio/user.slice/blkio.throttle.{read|write}_iops_device and run them in the user.slice or user.slice/test1 cgroup. However, if I throttle at the root of blkio using echo 8:32 10 > /sys/fs/cgroup/blkio/blkio.throttle.{read|write}_iops_device, and then run stress-ng processes, iostat 5 shows the tps for sdc is 10-11.

Does blkio throttling only work at the root level? The manual pages does not seem to suggest that.

已采纳解答

原帖链接 · Jeff Kubina · CC BY-SA 3.0

So the issue, which I learned from the answer to this question, is that kernel buffering bypasses the blkio system. Using fio with no buffering and directio I was able to throttle the iops to a device to 10 per second using echo 8:32 10 > /sys/fs/cgroup/blkio/user.slice/blkio.throttle.{read|write}_iops_device

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-04-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。