Re: [PATCH] memcg: hugetlbfs basic usage accounting

From: Tejun Heo
Date: Tue Nov 14 2017 - 16:06:24 EST


On Tue, Nov 14, 2017 at 05:24:29PM +0000, Roman Gushchin wrote:
> This patch implements basic accounting of memory consumption
> by hugetlbfs pages for cgroup v2 memory controller.
>
> Cgroup v2 memory controller lacks any visibility into the
> hugetlbfs memory consumption. Cgroup v1 implemented a separate
> hugetlbfs controller, which provided such stats, and also
> provided some control abilities. Although porting of the
> hugetlbfs controller to cgroup v2 is arguable a good idea and
> is outside of scope of this patch, it's very useful to have
> basic stats provided by memory.stat.
>
> As hugetlbfs memory can easily represent a big portion of total
> memory, it's important to understand who (which memcg/container)
> is using it.
>
> The number is represented in memory.stat as "hugetlb" in bytes and
> is printed unconditionally. Accounting code doesn't depend on
> cgroup v1 hugetlb controller.
>
> Example:
> $ cat /sys/fs/cgroup/user.slice/user-0.slice/session-1.scope/memory.stat
> anon 1634304
> file 1163264
> kernel_stack 16384
> slab 737280
> sock 0
> shmem 0
> file_mapped 32768
> file_dirty 4096
> file_writeback 0
> inactive_anon 0
> active_anon 1634304
> inactive_file 65536
> active_file 1097728
> unevictable 0
> slab_reclaimable 282624
> slab_unreclaimable 454656
> hugetlb 1073741824
> pgfault 4580
> pgmajfault 13
> ...
>
> Signed-off-by: Roman Gushchin <guro@xxxxxx>
> Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
> Cc: Michal Hocko <mhocko@xxxxxxxxxx>
> Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: Tejun Heo <tj@xxxxxxxxxx>
> Cc: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
> Cc: Dave Hansen <dave.hansen@xxxxxxxxx>
> Cc: kernel-team@xxxxxx
> Cc: cgroups@xxxxxxxxxxxxxxx
> Cc: linux-mm@xxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx

Acked-by: Tejun Heo <tj@xxxxxxxxxx>

Thanks.

--
tejun