From: Jiayuan Chen memory.max has the same high-latency reclaim loop as memory.high, and may additionally invoke the OOM killer on a cgroup that is already going away, further delaying its removal. Mitigate this by bailing out of the loop once memcg_is_dying(). Reported-by: Zhou Yingfu Cc: Jiayuan Chen Signed-off-by: Jiayuan Chen --- mm/memcontrol.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2d5cd056a25e..06bde6c5318f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4847,6 +4847,9 @@ static ssize_t memory_max_write(struct kernfs_open_file *of, if (signal_pending(current)) break; + if (memcg_is_dying(memcg)) + break; + if (!drained) { drain_all_stock(memcg); drained = true; -- 2.43.0