From: Michal Hocko <mhocko@suse.com>
To: Rik van Riel <riel@surriel.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
kernel-team@meta.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.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
Subject: Re: [PATCH] mm: allow exiting processes to exceed the memory.max limit
Date: Mon, 9 Dec 2024 19:08:19 +0100 [thread overview]
Message-ID: <Z1cyExTkg3OoaJy5@tiehlicka> (raw)
In-Reply-To: <20241209124233.3543f237@fangorn>
On Mon 09-12-24 12:42:33, Rik van Riel wrote:
> It is possible for programs to get stuck in exit, when their
> memcg is at or above the memory.max limit, and things like
> the do_futex() call from mm_release() need to page memory in.
>
> This can hang forever, but it really doesn't have to.
Are you sure this is really happening?
>
> The amount of memory that the exit path will page into memory
> should be relatively small, and letting exit proceed faster
> will free up memory faster.
>
> Allow PF_EXITING tasks to bypass the cgroup memory.max limit
> the same way PF_MEMALLOC already does.
>
> Signed-off-by: Rik van Riel <riel@surriel.com>
> ---
> mm/memcontrol.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 7b3503d12aaf..d1abef1138ff 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2218,11 +2218,12 @@ int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,
>
> /*
> * Prevent unbounded recursion when reclaim operations need to
> - * allocate memory. This might exceed the limits temporarily,
> - * but we prefer facilitating memory reclaim and getting back
> - * under the limit over triggering OOM kills in these cases.
> + * allocate memory, or the process is exiting. This might exceed
> + * the limits temporarily, but we prefer facilitating memory reclaim
> + * and getting back under the limit over triggering OOM kills in
> + * these cases.
> */
> - if (unlikely(current->flags & PF_MEMALLOC))
> + if (unlikely(current->flags & (PF_MEMALLOC | PF_EXITING)))
> goto force;
We already have task_is_dying() bail out. Why is that insufficient?
It is currently hitting when the oom situation is triggered while your
patch is triggering this much earlier. We used to do that in the past
but this got changed by a4ebf1b6ca1e ("memcg: prohibit unconditional
exceeding the limit of dying tasks"). I believe the situation in vmalloc
has changed since then but I suspect the fundamental problem that the
amount of memory dying tasks could allocate a lot of memory stays.
There is still this
: It has been observed that it is not really hard to trigger these
: bypasses and cause global OOM situation.
that really needs to be re-evaluated.
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2024-12-09 18:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-09 17:42 Rik van Riel
2024-12-09 18:08 ` Michal Hocko [this message]
2024-12-09 20:00 ` Rik van Riel
2024-12-11 16:28 ` Rik van Riel
2024-12-12 20:45 ` Johannes Weiner
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=Z1cyExTkg3OoaJy5@tiehlicka \
--to=mhocko@suse.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=muchun.song@linux.dev \
--cc=riel@surriel.com \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
/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