Skip to content

RFC Add memory.max.effective for application's allocators

Michal Koutný cgroups linux-doc linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v5 RFC Latest3 patches 3 repliesIn review

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3memcg: Add memory.max.effective attributeDocumentation/admin-guide/cgroup-v2.rst mm/memcontrol.c+24 -00 replies
2/3memcg: Add memory.swap.max.effective like hierarchical_memsw_limitmm/memcontrol.c+18 -00 replies
3/3memcg: Notify on memory.max.effective changesinclude/linux/memcontrol.h mm/memcontrol.c+12 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [RFC PATCH v5 0/3] Add memory.max.effective for application's allocators

Some applications use memory cgroup limits to scale their own memory needs. Reading of the immediate membership cgroup's memory.max is not sufficient because of possible ancestral limits. The application could traverse upwards to figure out the tightest limit but this would not work in cgroup namespace where the view of cgroup hierarchy is incomplete and the limit may apply from outer world. Additionally, applications should respond to limit changes.

(cgroup v1 used memory.stat:hierarchical_memory_limit to report the value but there's no such counterpart in cgroup v2 memory.stat.)

Introduce a new memcg attribute file that contains the effective value of memory limit for given cgroup (following cpuset.cpus.effective pattern) and that sends notifications like memory.events when the effective limit changes.

Reasons for RFC:
1) Should global limit be included? (And respond to memory hotplug?)
2) Is swap.max.effective needed? (in v2 without memsw accounting)
3) Should memory.high be also handled?
4) What would be an alternative?

My answers to RFC:

1) No (there's no memory.max in global root memcg)
2) No (app doesn't have full control of memory that's swapped out)
3) No (scaling the allocator against the "soft" limit could end up in dynamics difficult to reason and admin)
4)
- PSI (too obscure for traditional users but better semantics for limit shrinking)
- memory.stat field (like v1 but separate attribute is better for notifications, cpuset precedent)

Changes from v4 (https://lore.kernel.org/r/[email protected])
- split the patch for swap.max.effetive
- add Documentation/
- reword commit messages
- add notification support

Michal Koutný (3):
memcg: Add memory.max.effective attribute
memcg: Add memory.swap.max.effective like hierarchical_memsw_limit
memcg: Notify on memory.max.effective changes

 Documentation/admin-guide/cgroup-v2.rst |  6 ++++
 include/linux/memcontrol.h              |  2 ++
 mm/memcontrol.c                         | 46 +++++++++++++++++++++++++
 3 files changed, 54 insertions(+)

base-commit: 2df0193e62cf887f373995fb8a91068562784adc

Signature · 1 line
2.45.1