Commit a8c49af
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
[yosryahmed@google.com: v2]
Link: https://lkml.kernel.org/r/20220203193856.972500-1-yosryahmed@google.com
Link: https://lkml.kernel.org/r/20220201200823.3283171-1-yosryahmed@google.com
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>1 parent 086f694 commit a8c49af
File tree
3 files changed
+27
-6
lines changed- Documentation/admin-guide
- include/linux
- mm
3 files changed
+27
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1301 | 1301 | | |
1302 | 1302 | | |
1303 | 1303 | | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
1304 | 1309 | | |
1305 | 1310 | | |
1306 | 1311 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1371 | 1371 | | |
1372 | 1372 | | |
1373 | 1373 | | |
| 1374 | + | |
1374 | 1375 | | |
1375 | 1376 | | |
1376 | 1377 | | |
| |||
2114 | 2115 | | |
2115 | 2116 | | |
2116 | 2117 | | |
| 2118 | + | |
2117 | 2119 | | |
2118 | 2120 | | |
2119 | 2121 | | |
| |||
2124 | 2126 | | |
2125 | 2127 | | |
2126 | 2128 | | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
2127 | 2132 | | |
2128 | 2133 | | |
2129 | 2134 | | |
| |||
2979 | 2984 | | |
2980 | 2985 | | |
2981 | 2986 | | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
2982 | 2999 | | |
2983 | 3000 | | |
2984 | 3001 | | |
| |||
2991 | 3008 | | |
2992 | 3009 | | |
2993 | 3010 | | |
2994 | | - | |
2995 | | - | |
| 3011 | + | |
2996 | 3012 | | |
2997 | 3013 | | |
2998 | 3014 | | |
| |||
3018 | 3034 | | |
3019 | 3035 | | |
3020 | 3036 | | |
3021 | | - | |
3022 | | - | |
| 3037 | + | |
3023 | 3038 | | |
3024 | 3039 | | |
3025 | 3040 | | |
| |||
6801 | 6816 | | |
6802 | 6817 | | |
6803 | 6818 | | |
6804 | | - | |
6805 | | - | |
| 6819 | + | |
| 6820 | + | |
6806 | 6821 | | |
6807 | 6822 | | |
6808 | 6823 | | |
| |||
0 commit comments