Hello Waiman, On Fri, 09 Feb 2024 23:51:54 +0800, Waiman Long wrote: > I don't think we use mi->memsw in cgroup v2, only memory and swap should > be used. you are right, thanks: struct mem_cgroup { ... union { struct page_counter swap; /* v2 only */ struct page_counter memsw; /* v1 only */ }; Jan Kratochvil Signed-off-by: Jan Kratochvil (Azul) <jkratochvil@xxxxxxxx> mm/memcontrol.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 46d8d0211..2631dd810 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1636,6 +1636,8 @@ static inline unsigned long memcg_page_state_local_output( static void memcg_stat_format(struct mem_cgroup *memcg, struct seq_buf *s) { int i; + unsigned long memory, swap; + struct mem_cgroup *mi; /* * Provide statistics on the state of the memory subsystem as @@ -1682,6 +1684,17 @@ static void memcg_stat_format(struct mem_cgroup *memcg, struct seq_buf *s) memcg_events(memcg, memcg_vm_event_stat[i])); } + /* Hierarchical information */ + memory = swap = PAGE_COUNTER_MAX; + for (mi = memcg; mi; mi = parent_mem_cgroup(mi)) { + memory = min(memory, READ_ONCE(mi->memory.max)); + swap = min(swap, READ_ONCE(mi->swap.max)); + } + seq_buf_printf(s, "hierarchical_memory_limit %llu\n", + (u64)memory * PAGE_SIZE); + seq_buf_printf(s, "hierarchical_swap_limit %llu\n", + (u64)swap * PAGE_SIZE); + /* The above should easily fit into one page */ WARN_ON_ONCE(seq_buf_has_overflowed(s)); }