This is an updated patchset following some excellent comments from Roman and Longman. [1] As suggested, I've broken this into two commits: 1) with the implementation changes 2) extending the tests tests I haven't been able to induce anything problematic, but I'm a bit unclear as to whether there's reference counting on cgroups such that we don't need to handle the case where the cgroup is freed before the one of the peak files is closed. Documentation/admin-guide/cgroup-v2.rst | 26 ++- include/linux/cgroup.h | 8 + include/linux/memcontrol.h | 5 + include/linux/page_counter.h | 11 +- kernel/cgroup/cgroup-internal.h | 2 + kernel/cgroup/cgroup.c | 7 + mm/memcontrol.c | 129 +++++++++++++-- mm/page_counter.c | 36 ++++- tools/testing/selftests/cgroup/cgroup_util.c | 22 +++ tools/testing/selftests/cgroup/cgroup_util.h | 2 + tools/testing/selftests/cgroup/test_memcontrol.c | 227 ++++++++++++++++++++++++++- 11 files changed, 444 insertions(+), 31 deletions(-) [1]: https://lore.kernel.org/cgroups/20240722151713.2724855-1-davidf@xxxxxxxxx/T/ Thank you for your efforts and reviews, David Finkel Senior Principal Software Engineer Vimeo Inc.