linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] docs: cgroup: document empty-write behavior of memory limit knobs
@ 2026-08-26  2:17 Tao Cui
  2026-08-26 19:57 ` Michal Hocko
  2026-08-26 21:45 ` Shakeel Butt
  0 siblings, 2 replies; 3+ messages in thread
From: Tao Cui @ 2026-08-26  2:17 UTC (permalink / raw)
  To: tj, akpm, shakeel.butt, mhocko
  Cc: mhocko, mkoutny, hannes, roman.gushchin, muchun.song, linux-mm,
	cgroups, linux-kernel, cui.tao, Tao Cui

From: Tao Cui <cuitao@kylinos.cn>

A maintenance script on a cluster wrote an unset variable into
memory.max of a workload cgroup; the variable expanded to an empty
string, the write succeeded, and the workload in the cgroup was
OOM-killed.  Nothing pointed back at the write, so it took quite
some time to trace the OOM kills to that script.

The memory controller documentation does not say what an empty
write does; the cpuset controller documents its empty-value
semantics.  The actual behavior is that the empty string is
accepted as 0.  Reproduced on a k8s cluster (v1.29, cgroup v2,
two-container pod, 384M limit):

  # LIMIT=
  # echo "$LIMIT" > $CG/memory.max
  # echo $?
  0

  m6demo   0/2     OOMKilled   0

  Memory cgroup out of memory: Killed process 339529 (sleep) ... anon-rss:32kB

State it where the interface files are introduced, alongside the
existing notes on units and page rounding.

Link: https://lore.kernel.org/all/aoVUlFdZYLFn_gvJ@tiehlicka/
Signed-off-by: Tao Cui <cuitao@kylinos.cn>

---

Changes since v1: document the empty-write behavior instead of
rejecting it, the outcome of the review discussion at the Link:
below.

---
 Documentation/admin-guide/cgroup-v2.rst | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
index 86a2a0099178..8d2603751c51 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -1321,6 +1321,10 @@ All memory amounts are in bytes.  If a value which is not aligned to
 PAGE_SIZE is written, the value may be rounded up to the closest
 PAGE_SIZE multiple when read back.
 
+For the limit files described below, an empty or all-whitespace
+write is accepted and sets the limit to 0.  To disable a limit,
+write "max"; to set it to zero explicitly, write "0".
+
   memory.current
 	A read-only single value file which exists on non-root
 	cgroups.
-- 
2.43.0



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

* Re: [PATCH v2] docs: cgroup: document empty-write behavior of memory limit knobs
  2026-08-26  2:17 [PATCH v2] docs: cgroup: document empty-write behavior of memory limit knobs Tao Cui
@ 2026-08-26 19:57 ` Michal Hocko
  2026-08-26 21:45 ` Shakeel Butt
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2026-08-26 19:57 UTC (permalink / raw)
  To: Tao Cui
  Cc: tj, akpm, shakeel.butt, mkoutny, hannes, roman.gushchin,
	muchun.song, linux-mm, cgroups, linux-kernel, Tao Cui

On Wed 26-08-26 10:17:53, Tao Cui wrote:
> From: Tao Cui <cuitao@kylinos.cn>
> 
> A maintenance script on a cluster wrote an unset variable into
> memory.max of a workload cgroup; the variable expanded to an empty
> string, the write succeeded, and the workload in the cgroup was
> OOM-killed.  Nothing pointed back at the write, so it took quite
> some time to trace the OOM kills to that script.
> 
> The memory controller documentation does not say what an empty
> write does; the cpuset controller documents its empty-value
> semantics.  The actual behavior is that the empty string is
> accepted as 0.  Reproduced on a k8s cluster (v1.29, cgroup v2,
> two-container pod, 384M limit):
> 
>   # LIMIT=
>   # echo "$LIMIT" > $CG/memory.max
>   # echo $?
>   0
> 
>   m6demo   0/2     OOMKilled   0
> 
>   Memory cgroup out of memory: Killed process 339529 (sleep) ... anon-rss:32kB
> 
> State it where the interface files are introduced, alongside the
> existing notes on units and page rounding.
> 
> Link: https://lore.kernel.org/all/aoVUlFdZYLFn_gvJ@tiehlicka/
> Signed-off-by: Tao Cui <cuitao@kylinos.cn>

Acked-by: Michal Hocko <mhocko@suse.com>
Thanks!

> 
> ---
> 
> Changes since v1: document the empty-write behavior instead of
> rejecting it, the outcome of the review discussion at the Link:
> below.
> 
> ---
>  Documentation/admin-guide/cgroup-v2.rst | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
> index 86a2a0099178..8d2603751c51 100644
> --- a/Documentation/admin-guide/cgroup-v2.rst
> +++ b/Documentation/admin-guide/cgroup-v2.rst
> @@ -1321,6 +1321,10 @@ All memory amounts are in bytes.  If a value which is not aligned to
>  PAGE_SIZE is written, the value may be rounded up to the closest
>  PAGE_SIZE multiple when read back.
>  
> +For the limit files described below, an empty or all-whitespace
> +write is accepted and sets the limit to 0.  To disable a limit,
> +write "max"; to set it to zero explicitly, write "0".
> +
>    memory.current
>  	A read-only single value file which exists on non-root
>  	cgroups.
> -- 
> 2.43.0

-- 
Michal Hocko
SUSE Labs


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

* Re: [PATCH v2] docs: cgroup: document empty-write behavior of memory limit knobs
  2026-08-26  2:17 [PATCH v2] docs: cgroup: document empty-write behavior of memory limit knobs Tao Cui
  2026-08-26 19:57 ` Michal Hocko
@ 2026-08-26 21:45 ` Shakeel Butt
  1 sibling, 0 replies; 3+ messages in thread
From: Shakeel Butt @ 2026-08-26 21:45 UTC (permalink / raw)
  To: Tao Cui
  Cc: tj, akpm, mhocko, mhocko, mkoutny, hannes, roman.gushchin,
	muchun.song, linux-mm, cgroups, linux-kernel, Tao Cui

On Wed, Aug 26, 2026 at 10:17:53AM +0800, Tao Cui wrote:
> From: Tao Cui <cuitao@kylinos.cn>
> 
> A maintenance script on a cluster wrote an unset variable into
> memory.max of a workload cgroup; the variable expanded to an empty
> string, the write succeeded, and the workload in the cgroup was
> OOM-killed.  Nothing pointed back at the write, so it took quite
> some time to trace the OOM kills to that script.
> 
> The memory controller documentation does not say what an empty
> write does; the cpuset controller documents its empty-value
> semantics.  The actual behavior is that the empty string is
> accepted as 0.  Reproduced on a k8s cluster (v1.29, cgroup v2,
> two-container pod, 384M limit):
> 
>   # LIMIT=
>   # echo "$LIMIT" > $CG/memory.max
>   # echo $?
>   0
> 
>   m6demo   0/2     OOMKilled   0
> 
>   Memory cgroup out of memory: Killed process 339529 (sleep) ... anon-rss:32kB
> 
> State it where the interface files are introduced, alongside the
> existing notes on units and page rounding.
> 
> Link: https://lore.kernel.org/all/aoVUlFdZYLFn_gvJ@tiehlicka/
> Signed-off-by: Tao Cui <cuitao@kylinos.cn>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>


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

end of thread, other threads:[~2026-08-26 21:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-26  2:17 [PATCH v2] docs: cgroup: document empty-write behavior of memory limit knobs Tao Cui
2026-08-26 19:57 ` Michal Hocko
2026-08-26 21:45 ` Shakeel Butt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).