I have some questions on cgroup blkio controller.
I want to limit the IOPS on a specific process. This process uses IO redirection to write the stdout contents into a file. I tried to put the process into a cgroup. However, it seems the cgroup didn't catch the IO operations on the process, thus not able to limit the IOPS.
I did a small experiment to simulate the process. Here's what I did:
cgexec -g blkio:/dummy_group --sticky dd bs=1 if=/dev/zero of=/dev/stdout count=30000000 > /tmp/test
I planed to generate a 30MB file using dd, output it to the stdout, and then redirect to the file. I expected the write operations should be recorded in the cgroup statistics. However, when I read the "/cgroup/blkio/dummy_group/blkio.throttle.io_serviced" file, the 'Write' number didn't change !
Then I did the similar tasks using cp command, the 'Write' number really changed:
cgexec -g blkio:/dummy_group --sticky cp /tmp/test /tmp/test2
I'm wondering if I've done something wrong to achieve this goal. What's the correct method to monitor and limit processes whose IO is performed using IO redirection?