Re: [RFC 2/2] memcg: Adapt cgroup.top into per-memcg

From: Michal Hocko
Date: Fri Aug 26 2022 - 03:38:25 EST


On Fri 26-08-22 09:15:03, Lu Jialin wrote:
> cgroup.top is able to show resource usage information for each cgroups.
> Currently only memory usage is monitored ,including usage,anon,file,
> kmem(Bytes), stats for other resource types would be added as well.
>
> Show case:
> / # mount -t cgroup2 none /sys/fs/cgroup
> / # cd /sys/fs/cgroup/
> /sys/fs/cgroup # echo "+memory" > cgroup.subtree_control
> /sys/fs/cgroup # mkdir test1
> /sys/fs/cgroup # mkdir test2
> /sys/fs/cgroup # mkdir test3
> /sys/fs/cgroup # echo $$ > test2/cgroup.procs
> /sys/fs/cgroup # cd /test
> /test # ./memcg_malloc 512000 &
> /test # ./memcg_malloc 512000 &
> /test # ./memcg_malloc 512000 &
> /test # cd /sys/fs/cgroup
> /sys/fs/cgroup # echo $$ > test1/cgroup.procs
> /sys/fs/cgroup # cd /test
> /test # ./memcg_malloc 512000 &
> /test # cd /sys/fs/cgroup
> /sys/fs/cgroup # echo $$ > test3/cgroup.procs
> /sys/fs/cgroup # cat cgroup.top
> memory top:
> name usage anon file kernel
> test2 1974272 1671168 0 270336
> test1 700416 569344 0 94208
> test3 196608 86016 0 86016

This information is already present in memory.stat and can be easily
post-processed to generate similar output. Why is that insufficient?
--
Michal Hocko
SUSE Labs