linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/5] add option to restore swap account to cgroupv1 mode
@ 2025-03-19  6:41 Jingxiang Zeng
  2025-03-19  6:41 ` [RFC 1/5] Kconfig: add SWAP_CHARGE_V1_MODE config Jingxiang Zeng
                   ` (6 more replies)
  0 siblings, 7 replies; 28+ messages in thread
From: Jingxiang Zeng @ 2025-03-19  6:41 UTC (permalink / raw)
  To: akpm
  Cc: linux-mm, cgroups, linux-kernel, hannes, mhocko, roman.gushchin,
	shakeel.butt, muchun.song, kasong, Zeng Jingxiang

From: Zeng Jingxiang <linuszeng@tencent.com>

memsw account is a very useful knob for container memory
overcommitting: It's a great abstraction of the "expected total
memory usage" of a container, so containers can't allocate too
much memory using SWAP, but still be able to SWAP out.

For a simple example, with memsw.limit == memory.limit, containers
can't exceed their original memory limit, even with SWAP enabled, they
get OOM killed as how they used to, but the host is now able to
offload cold pages.

Similar ability seems absent with V2: With memory.swap.max == 0, the
host can't use SWAP to reclaim container memory at all. But with a
value larger than that, containers are able to overuse memory, causing
delayed OOM kill, thrashing, CPU/Memory usage ratio could be heavily
out of balance, especially with compress SWAP backends.

This patch set adds two interfaces to control the behavior of the
memory.swap.max/current in cgroupv2:

CONFIG_MEMSW_ACCOUNT_ON_DFL
cgroup.memsw_account_on_dfl={0, 1}

When one of the interfaces is enabled: memory.swap.current and
memory.swap.max represents the usage/limit of swap.
When neither is enabled (default behavior),memory.swap.current and
memory.swap.max represents the usage/limit of memory+swap.

As discussed in [1], this patch set can change the semantics of
of memory.swap.max/current to the v1-like behavior.

Link:
https://lore.kernel.org/all/Zk-fQtFrj-2YDJOo@P9FQF9L96D.corp.robot.car/ [1]

linuszeng (5):
  Kconfig: add SWAP_CHARGE_V1_MODE config
  memcontrol: add boot option to enable memsw account on dfl
  mm/memcontrol: do not scan anon pages if memsw limit is hit
  mm/memcontrol: allow memsw account in cgroup v2
  Docs/cgroup-v2: add cgroup.memsw_account_on_dfl Documentation

 Documentation/admin-guide/cgroup-v2.rst       | 21 +++++--
 .../admin-guide/kernel-parameters.txt         |  7 +++
 include/linux/memcontrol.h                    |  8 +++
 init/Kconfig                                  | 16 ++++++
 mm/memcontrol-v1.c                            |  2 +-
 mm/memcontrol-v1.h                            |  4 +-
 mm/memcontrol.c                               | 55 ++++++++++++++-----
 7 files changed, 93 insertions(+), 20 deletions(-)

-- 
2.41.1



^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2025-05-05 18:29 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-19  6:41 [RFC 0/5] add option to restore swap account to cgroupv1 mode Jingxiang Zeng
2025-03-19  6:41 ` [RFC 1/5] Kconfig: add SWAP_CHARGE_V1_MODE config Jingxiang Zeng
2025-03-19 19:29   ` Shakeel Butt
2025-03-19 19:31     ` Shakeel Butt
2025-03-19  6:41 ` [RFC 2/5] memcontrol: add boot option to enable memsw account on dfl Jingxiang Zeng
2025-03-19 19:34   ` Shakeel Butt
2025-03-19 22:30     ` Roman Gushchin
2025-03-20  8:43       ` jingxiang zeng
2025-03-20 14:28       ` Johannes Weiner
2025-03-20 15:16         ` Roman Gushchin
2025-03-20 15:33         ` Shakeel Butt
2025-04-02 13:40           ` Michal Koutný
2025-04-03  7:47             ` [External] " Zhongkun He
2025-04-03  9:16               ` jingxiang zeng
2025-04-11 16:57                 ` Michal Koutný
2025-04-16  8:29                   ` jingxiang zeng
2025-05-05 18:29                     ` Michal Koutný
2025-03-20  8:51     ` jingxiang zeng
2025-03-19  6:41 ` [RFC 3/5] mm/memcontrol: do not scan anon pages if memsw limit is hit Jingxiang Zeng
2025-03-19 19:36   ` Shakeel Butt
2025-03-20  8:40     ` jingxiang zeng
2025-03-19  6:41 ` [RFC 4/5] mm/memcontrol: allow memsw account in cgroup v2 Jingxiang Zeng
2025-03-19  6:41 ` [RFC 5/5] Docs/cgroup-v2: add cgroup.memsw_account_on_dfl Documentation Jingxiang Zeng
2025-03-19 19:27 ` [RFC 0/5] add option to restore swap account to cgroupv1 mode Shakeel Butt
2025-03-19 19:38 ` Johannes Weiner
2025-03-19 19:51   ` Shakeel Butt
2025-03-20  8:09   ` jingxiang zeng
2025-03-20 15:08     ` Johannes Weiner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox