[Devel] [PATCH 0/2 RH8] adopt cgroup-v2 writeback

Andrey Zhadchenko andrey.zhadchenko at virtuozzo.com
Tue Jul 6 20:53:29 MSK 2021


In cgroup-v1 all writeback IO is accounted to root blkcg by design. With
cgroup-v2 it became possible to link memcg and blkcg, so  writeback code
was enhanced to
1) consider balancing dirty pages per memory cgroup
2) account writeback generated IO to blkcg

In vz7 writeback were balancing beancounter cgroup. However we dropped
it.
In vz8 @aryabinin tried to enable cgroup-v2 wruteback with 5cc286c98ee20
("mm, cgroup, writeback: Enable per-cgroup writeback for v1 cgroup."),
but cgroup_get_e_css(), which is used to find blkcg based on memcg,
do not work well with cgroup-v1 and always returns root blkcg.
However we can implement a new function to associate blkcg with memcg via
ve css_set.

Test results with 256M container without patch:
# echo "253:22358 100000000" > /sys/fs/cgroup/blkio/machine.slice/1/blkio.throttle.write_bps_device 
# vzctl exec 1 dd if=/dev/zero of=/test bs=1M count=1000
# 1048576000 bytes (1.0 GB, 1000 MiB) copied, 1.35522 s, 774 MB/s
Since dirty balancing is global, conainer can dirty more than it's RAM
and blkio limits is not respected.

With patch
# echo "253:22765 100000000" > /sys/fs/cgroup/blkio/machine.slice/1/blkio.throttle.write_bps_device 
# vzctl exec 1 dd if=/dev/zero of=/test bs=1M count=1000
# 1048576000 bytes (1.0 GB, 1000 MiB) copied, 10.2267 s, 103 MB/s
Per-ve dirty balancing and throttling works as expected.

Andrey Zhadchenko (2):
  kernel/cgroup: implement cgroup_get_e_ve_css
  mm/backing-dev: associate writeback with correct blkcg

 include/linux/cgroup.h |  2 ++
 kernel/cgroup/cgroup.c | 29 +++++++++++++++++++++++++++++
 mm/backing-dev.c       | 17 +++++++++++++++++
 3 files changed, 48 insertions(+)

-- 
1.8.3.1


More information about the Devel mailing list