From: Balbir Singh <balbirs@nvidia.com>
To: Rik van Riel <riel@surriel.com>, Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Muchun Song <muchun.song@linux.dev>,
Andrew Morton <akpm@linux-foundation.org>,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, kernel-team@meta.com,
Nhat Pham <nphamcs@gmail.com>,
Yosry Ahmed <yosryahmed@google.com>
Subject: Re: [PATCH] memcg: allow exiting tasks to write back data to swap
Date: Thu, 12 Dec 2024 10:15:35 +1100 [thread overview]
Message-ID: <766a28a1-c82b-46fd-b3b0-fe3b6024f462@nvidia.com> (raw)
In-Reply-To: <20241211105336.380cb545@fangorn>
On 12/12/24 02:53, Rik van Riel wrote:
> A task already in exit can get stuck trying to allocate pages, if its
> cgroup is at the memory.max limit, the cgroup is using zswap, but
> zswap writeback is enabled, and the remaining memory in the cgroup is
> not compressible.
>
> This seems like an unlikely confluence of events, but it can happen
> quite easily if a cgroup is OOM killed due to exceeding its memory.max
> limit, and all the tasks in the cgroup are trying to exit simultaneously.
>
> When this happens, it can sometimes take hours for tasks to exit,
> as they are all trying to squeeze things into zswap to bring the group's
> memory consumption below memory.max.
>
> Allowing these exiting programs to push some memory from their own
> cgroup into swap allows them to quickly bring the cgroup's memory
> consumption below memory.max, and exit in seconds rather than hours.
>
> Loading this fix as a live patch on a system where a workload got stuck
> exiting allowed the workload to exit within a fraction of a second.
>
> Signed-off-by: Rik van Riel <riel@surriel.com>
> ---
> mm/memcontrol.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 7b3503d12aaf..03d77e93087e 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -5371,6 +5371,15 @@ bool mem_cgroup_zswap_writeback_enabled(struct mem_cgroup *memcg)
> if (!zswap_is_enabled())
> return true;
>
> + /*
> + * Always allow exiting tasks to push data to swap. A process in
> + * the middle of exit cannot get OOM killed, but may need to push
> + * uncompressible data to swap in order to get the cgroup memory
> + * use below the limit, and make progress with the exit.
> + */
> + if ((current->flags & PF_EXITING) && memcg == mem_cgroup_from_task(current))
> + return true;
> +
> for (; memcg; memcg = parent_mem_cgroup(memcg))
> if (!READ_ONCE(memcg->zswap_writeback))
> return false;
Rik,
I am unable to understand the motivation here, so we want
mem_cgroup_zswap_writeback_enabled() to return true, it only
returns false if a memcg in the hierarchy has zswap_writeback
set to 0 (false). In my git-grep I can't seem to find how/why
that may be the case. I can see memcg starts of with the value
set to true, if CONFIG_ZSWAP is enabled.
Your changelog above makes sense, but I am unable to map it to
the code changes.
Balbir
next prev parent reply other threads:[~2024-12-11 23:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-11 15:53 Rik van Riel
2024-12-11 16:26 ` Yosry Ahmed
2024-12-11 16:34 ` Rik van Riel
2024-12-11 17:00 ` Yosry Ahmed
2024-12-11 17:19 ` Rik van Riel
2024-12-11 17:30 ` Yosry Ahmed
2024-12-11 17:49 ` Rik van Riel
2024-12-11 23:15 ` Balbir Singh [this message]
2024-12-12 1:21 ` Rik van Riel
2024-12-12 3:25 ` Balbir Singh
2024-12-12 14:03 ` Rik van Riel
2024-12-12 23:39 ` Balbir Singh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=766a28a1-c82b-46fd-b3b0-fe3b6024f462@nvidia.com \
--to=balbirs@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=nphamcs@gmail.com \
--cc=riel@surriel.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=yosryahmed@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox