Linux Documentation
 help / color / mirror / Atom feed
* [PATCH] Docs/admin-guide/cgroup-v1/memory: document memsw limit constraints
@ 2026-07-23 12:43 Shaojie Sun
  2026-07-24 10:21 ` [PATCH v2] " Shaojie Sun
  0 siblings, 1 reply; 3+ messages in thread
From: Shaojie Sun @ 2026-07-23 12:43 UTC (permalink / raw)
  To: tj, hannes, mkoutny, corbet, skhan
  Cc: cgroups, linux-doc, linux-kernel, Shaojie Sun

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


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

end of thread, other threads:[~2026-07-24 11:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-23 12:43 [PATCH] Docs/admin-guide/cgroup-v1/memory: document memsw limit constraints Shaojie Sun
2026-07-24 10:21 ` [PATCH v2] " Shaojie Sun
2026-07-24 11:37   ` Michal Koutný

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