Re: [PATCH] mm: memcg: add swapcache stat for memcg v2

From: Michal Hocko
Date: Wed Jan 06 2021 - 09:54:39 EST


On Thu 31-12-20 18:39:55, Shakeel Butt wrote:
> This patch adds swapcache stat for the cgroup v2. The swapcache
> represents the memory that is accounted against both the memory and the
> swap limit of the cgroup. The main motivation behind exposing the
> swapcache stat is for enabling users to gracefully migrate from cgroup
> v1's memsw counter to cgroup v2's memory and swap counters.
>
> Cgroup v1's memsw limit allows users to limit the memory+swap usage of a
> workload but without control on the exact proportion of memory and swap.
> Cgroup v2 provides separate limits for memory and swap which enables
> more control on the exact usage of memory and swap individually for the
> workload.
>
> With some little subtleties, the v1's memsw limit can be switched with
> the sum of the v2's memory and swap limits. However the alternative for
> memsw usage is not yet available in cgroup v2. Exposing per-cgroup
> swapcache stat enables that alternative. Adding the memory usage and
> swap usage and subtracting the swapcache will approximate the memsw
> usage. This will help in the transparent migration of the workloads
> depending on memsw usage and limit to v2' memory and swap counters.

Could you expand a bit more on why memsw usage is important even in
cgroup v2 land? How are you going to use the approximated value?

I am not really objecting to adding this counter. We do export it for
the global case and having a memcg view sounds useful for analysis.
--
Michal Hocko
SUSE Labs