On Thu, Mar 20, 2025 at 04:09:29PM +0800, jingxiang zeng wrote: > If both memsw.max and swap.max are provided in cgroupv2, there will be some > issues as follows: > (1. As Shakeel Butt mentioned, currently memsw and swap share the page_counter, > and we need to provide a separate page_counter for memsw. > (2. Currently, the statistics for memsw and swap are mutually > exclusive. For example, > during uncharging, both memsw and swap call the __mem_cgroup_uncharge_swap > function together, and this function currently only selects a single > counter for statistics > based on the static do_memsw_account. My suggestion is to factor out from struct page_counter all the stuff that is not necessary for all users, and then have separate counters for swap and memsw. The protection stuff is long overdue for this. It makes up nearly half of the struct's members, but is only used by the memory counter. Even before your patches this is unnecessary bloat in the swap/memsw, kmem and tcpmem counters. Fix that and having separate counters is a non-issue. Overloading the memory.swap.* controls to mean "combined memory and swap" is unacceptable to me. They have established meaning on v2. It may well become a common setting, and there might well be usecases where people want one setting for one cgroup and another setting for another cgroup. Or maybe even both controls in one group. And why not? This is a user-visible interface that we'll have to support forever, and deployments will be forced to use forever. Tech debt in the current implementation is not a convincing argument to forever trap us all with a suboptimal choice. Nacked-by: Johannes Weiner <hannes@xxxxxxxxxxx>