On Fri, Apr 28, 2023 at 01:24:06PM +0000, Yosry Ahmed wrote: > Commit c8713d0b2312 ("mm: memcontrol: dump memory.stat during cgroup > OOM") made sure we dump all the stats in memory.stat during a cgroup > OOM, but it also introduced a slight behavioral change. The code used to > print the non-hierarchical v1 cgroup stats for the entire cgroup > subtree, now it only prints the v2 cgroup stats for the cgroup under > OOM. > > For cgroup v1 users, this introduces a few problems: > (a) The non-hierarchical stats of the memcg under OOM are no longer > shown. > (b) A couple of v1-only stats (e.g. pgpgin, pgpgout) are no longer > shown. > (c) We show the list of cgroup v2 stats, even in cgroup v1. This list of > stats is not tracked with v1 in mind. While most of the stats seem to be > working on v1, there may be some stats that are not fully or correctly > tracked. > > Although OOM log is not set in stone, we should not change it for no > reason. When upgrading the kernel version to a version including > commit c8713d0b2312 ("mm: memcontrol: dump memory.stat during cgroup > OOM"), these behavioral changes are noticed in cgroup v1. > > The fix is simple. Commit c8713d0b2312 ("mm: memcontrol: dump memory.stat > during cgroup OOM") separated stats formatting from stats display for > v2, to reuse the stats formatting in the OOM logs. Do the same for v1. > > Move the v2 specific formatting from memory_stat_format() to > memcg_stat_format(), add memcg1_stat_format() for v1, and make > memory_stat_format() select between them based on cgroup version. > Since memory_stat_show() now works for both v1 & v2, drop > memcg_stat_show(). > > Signed-off-by: Yosry Ahmed <yosryahmed@xxxxxxxxxx> Acked-by: Shakeel Butt <shakeelb@xxxxxxxxxx>