Re: [PATCH mm-unstable RFC 3/5] memcg: calculate root usage from global state

From: Shakeel Butt
Date: Thu Apr 20 2023 - 14:58:17 EST


On Mon, Apr 3, 2023 at 3:03 PM Yosry Ahmed <yosryahmed@xxxxxxxxxx> wrote:
>
> Currently, we approximate the root usage by adding the memcg stats for
> anon, file, and conditionally swap (for memsw). To read the memcg stats
> we need to invoke an rstat flush. rstat flushes can be expensive, they
> scale with the number of cpus and cgroups on the system.
>
> mem_cgroup_usage() is called by memcg_events()->mem_cgroup_threshold()
> with irqs disabled, so such an expensive operation with irqs disabled
> can cause problems.
>
> Instead, approximate the root usage from global state. This is not 100%
> accurate, but the root usage has always been ill-defined anyway.
>
> Signed-off-by: Yosry Ahmed <yosryahmed@xxxxxxxxxx>

Acked-by: Shakeel Butt <shakeelb@xxxxxxxxxx>