]> Git Repo - linux.git/commit
memcg: add per-memcg total kernel memory stat
authorYosry Ahmed <[email protected]>
Tue, 22 Mar 2022 21:40:10 +0000 (14:40 -0700)
committerLinus Torvalds <[email protected]>
Tue, 22 Mar 2022 22:57:02 +0000 (15:57 -0700)
commita8c49af3be5f0b4e105ef678bcf14ef102c270be
tree80f2c4728361aa90b71fec915c6c8b347f85f97e
parent086f694a75e1a283a11f9afa7bae258f30892b81
memcg: add per-memcg total kernel memory stat

Currently memcg stats show several types of kernel memory: kernel stack,
page tables, sock, vmalloc, and slab.  However, there are other
allocations with __GFP_ACCOUNT (or supersets such as GFP_KERNEL_ACCOUNT)
that are not accounted in any of those stats, a few examples are:

 - various kvm allocations (e.g. allocated pages to create vcpus)
 - io_uring
 - tmp_page in pipes during pipe_write()
 - bpf ringbuffers
 - unix sockets

Keeping track of the total kernel memory is essential for the ease of
migration from cgroup v1 to v2 as there are large discrepancies between
v1's kmem.usage_in_bytes and the sum of the available kernel memory
stats in v2.  Adding separate memcg stats for all __GFP_ACCOUNT kernel
allocations is an impractical maintenance burden as there a lot of those
all over the kernel code, with more use cases likely to show up in the
future.

Therefore, add a "kernel" memcg stat that is analogous to kmem page
counter, with added benefits such as using rstat infrastructure which
aggregates stats more efficiently.  Additionally, this provides a
lighter alternative in case the legacy kmem is deprecated in the future

[[email protected]: v2]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Yosry Ahmed <[email protected]>
Acked-by: Shakeel Butt <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Muchun Song <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Documentation/admin-guide/cgroup-v2.rst
include/linux/memcontrol.h
mm/memcontrol.c
This page took 0.051696 seconds and 4 git commands to generate.