Skip to contentSkip to conversation

Memory reclaim documentation fixes

PATCH In review Michal Koutný 2 participants 5 messages Nov 14, 2025

Subsystems (2)
lore
Share & tools
lore

Michal Koutný

author maintainer
#0 lore raw

v2 cover Memory reclaim documentation fixes

I think the reclaim target is a concept that is not just an implementation detail and hence it should be documented how it applies to protection configuration (the first patch). Second patch is a "best practice" bit of information, it may be squashed with the first one. The last patch just makes docs indefinite until the idea is implemented.

Originally sent in [1], this is rebased and resent since I still think it'd be good to have the concept somewhere documented. (E.g. for the guys who are implementing protection for the dmem controller [2] to arrive at similar behavior.)

[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/r/[email protected]

v2:
- diagram syntax (Jonathan)

v1 (https://lore.kernel.org/r/[email protected]/)

Michal Koutný (3):
docs: cgroup: Explain reclaim protection target
docs: cgroup: Note about sibling relative reclaim protection
docs: cgroup: No special handling of unpopulated memcgs

 Documentation/admin-guide/cgroup-v2.rst | 31 ++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 6 deletions(-)

base-commit: 1c353dc8d962de652bc7ad2ba2e63f553331391c

Signature · 1 line
2.51.1
author maintainer
#1 lore raw

PATCH v2 1/3 docs: cgroup: Explain reclaim protection target

The protection target is necessary to understand how effective reclaim protection applies in the hierarchy.

---
 Documentation/admin-guide/cgroup-v2.rst | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +21 -3
index 0e6c67ac585a0..97a9f8a046c5f 100644
@@ -53,7 +53,8 @@ v1 is available under :ref:`Documentation/admin-guide/cgroup-v1/index.rst <cgrou
      5-2. Memory
        5-2-1. Memory Interface Files
        5-2-2. Usage Guidelines
-       5-2-3. Memory Ownership
+       5-2-3. Reclaim Protection
+       5-2-4. Memory Ownership
      5-3. IO
        5-3-1. IO Interface Files
        5-3-2. Writeback
@@ -1317,7 +1318,7 @@ PAGE_SIZE multiple when read back.
 	smaller overages.
 
 	Effective min boundary is limited by memory.min values of
-	all ancestor cgroups. If there is memory.min overcommitment
+	ancestor cgroups. If there is memory.min overcommitment
 	(child cgroup or cgroups are requiring more protected memory
 	than parent will allow), then each child cgroup will get
 	the part of parent's protection proportional to its
@@ -1343,7 +1344,7 @@ PAGE_SIZE multiple when read back.
 	smaller overages.
 
 	Effective low boundary is limited by memory.low values of
-	all ancestor cgroups. If there is memory.low overcommitment
+	ancestor cgroups. If there is memory.low overcommitment
 	(child cgroup or cgroups are requiring more protected memory
 	than parent will allow), then each child cgroup will get
 	the part of parent's protection proportional to its
@@ -1934,6 +1935,23 @@ memory - is necessary to determine whether a workload needs more
 memory; unfortunately, memory pressure monitoring mechanism isn't
 implemented yet.
 
+Reclaim Protection
+~~~~~~~~~~~~~~~~~~
+
+The protection configured with "memory.low" or "memory.min" applies relatively
+to the target of the reclaim (i.e. any of memory cgroup limits, proactive
+memory.reclaim or global reclaim apparently located in the root cgroup).
+The protection value configured for B applies unchanged to the reclaim
+targeting A (i.e. caused by competition with the sibling E)::
+
+		root - ... - A - B - C
+		              \    ` D
+		               ` E
+
+When the reclaim targets ancestors of A, the effective protection of B is
+capped by the protection value configured for A (and any other intermediate
+ancestors between A and the target).
+
 
 Memory Ownership
 ~~~~~~~~~~~~~~~~
Signature · 1 line
2.51.1
author maintainer
#2 lore raw

PATCH v2 2/3 docs: cgroup: Note about sibling relative reclaim protection

In reply to Michal Koutný
---
 Documentation/admin-guide/cgroup-v2.rst | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/admin-guide/cgroup-v2.rst +4 -0
index 97a9f8a046c5f..e0a659474fa47 100644
@@ -1952,6 +1952,10 @@ When the reclaim targets ancestors of A, the effective protection of B is
 capped by the protection value configured for A (and any other intermediate
 ancestors between A and the target).
 
+To express indifference about relative sibling protection, it is suggested to
+use memory_recursiveprot. Configuring all descendants of a parent with finite
+protection to "max" works but it may unnecessarily skew memory.events:low
+field.
 
 Memory Ownership
 ~~~~~~~~~~~~~~~~
Signature · 1 line
2.51.1
author maintainer
#3 lore raw

PATCH v2 3/3 docs: cgroup: No special handling of unpopulated memcgs

In reply to Michal Koutný

The current kernel doesn't handle unpopulated cgroups any special regarding reclaim protection. Furthermore, this wasn't a case even when this was introduced in

    bf8d5d52ffe89 ("memcg: introduce memory.min")

Drop the incorrect documentation. (Implementation taking into account the inner-node constraint may be added later.)

---
 Documentation/admin-guide/cgroup-v2.rst | 3 ---
 1 file changed, 3 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +0 -3
index e0a659474fa47..4c072e85acdfe 100644
@@ -1327,9 +1327,6 @@ PAGE_SIZE multiple when read back.
 	Putting more memory than generally available under this
 	protection is discouraged and may lead to constant OOMs.
 
-	If a memory cgroup is not populated with processes,
-	its memory.min is ignored.
-
   memory.low
 	A read-write single value file which exists on non-root
 	cgroups.  The default is "0".
Signature · 1 line
2.51.1
maintainer
#4 lore raw
In reply to Michal Koutný
Quoted 4 lines

Michal Koutný (3):
docs: cgroup: Explain reclaim protection target
docs: cgroup: Note about sibling relative reclaim protection
docs: cgroup: No special handling of unpopulated memcgs

Applied 1-3 to cgroup/for-6.19.

Thanks.

--
tejun