[PATCH] Docs/admin-guide/cgroup-v1/memory: document memsw limit constraints
Shaojie Sun <[email protected]> Thu, 23 Jul 2026 20:43:54 +0800
| Newsgroups | org.kernel.vger.cgroups,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> --- 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