[PATCH] Docs/admin-guide/cgroup-v1/memory: document memsw limit constraints

Shaojie Sun posted 1 patch 16 hours ago
Documentation/admin-guide/cgroup-v1/memory.rst | 9 +++++++++
1 file changed, 9 insertions(+)
[PATCH] Docs/admin-guide/cgroup-v1/memory: document memsw limit constraints
Posted by Shaojie Sun 16 hours ago
The kernel enforces the invariant that memory.max <= memsw.max, and
returns -EINVAL when writing an invalid memsw.limit_in_bytes without
first configuring memory.limit_in_bytes.  However, this constraint
is not documented anywhere, leaving users to discover it only through
-EINVAL errors.

Add a Note section explaining:
  - memory.limit_in_bytes must be set before memsw.limit_in_bytes
  - memory.limit_in_bytes <= memsw.limit_in_bytes must always hold
  - Violations result in -EINVAL

Signed-off-by: Shaojie Sun <sunshaojie@kylinos.cn>
---
 Documentation/admin-guide/cgroup-v1/memory.rst | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/admin-guide/cgroup-v1/memory.rst b/Documentation/admin-guide/cgroup-v1/memory.rst
index 7db63c002922..92e74ec28822 100644
--- a/Documentation/admin-guide/cgroup-v1/memory.rst
+++ b/Documentation/admin-guide/cgroup-v1/memory.rst
@@ -262,6 +262,15 @@ In this case, setting memsw.limit_in_bytes=3G will prevent bad use of swap.
 By using the memsw limit, you can avoid system OOM which can be caused by swap
 shortage.
 
+Note:
+ - Since memsw is the sum of memory and swap, it must be at least the memory
+   limit.  Therefore, ``memory.limit_in_bytes`` must be set before
+   ``memory.memsw.limit_in_bytes``, and the relation
+   ``memory.limit_in_bytes <= memory.memsw.limit_in_bytes`` must always hold.
+ - If ``memory.memsw.limit_in_bytes`` is set without a properly configured
+   ``memory.limit_in_bytes``, or if the above relation is violated, the write
+   will fail with ``-EINVAL``.
+
 2.4.1 why 'memory+swap' rather than swap
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-- 
2.25.1