From: Shakeel Butt <shakeelb@google.com>
To: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
Andrew Morton <akpm@linux-foundation.org>,
Michal Hocko <mhocko@kernel.org>,
Muchun Song <muchun.song@linux.dev>, Tejun Heo <tj@kernel.org>,
Dan Schatzberg <schatzberg.dan@gmail.com>,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: memcontrol: don't throttle dying tasks on memory.high
Date: Fri, 12 Jan 2024 13:27:54 -0800 [thread overview]
Message-ID: <CALvZod5nLdpLgweBU0MtsMzBK=vTnJnRgr5FAhku3d=Atw1Cow@mail.gmail.com> (raw)
In-Reply-To: <ZaGoSdNpouolFHdT@P9FQF9L96D.corp.robot.car>
On Fri, Jan 12, 2024 at 1:00 PM Roman Gushchin <roman.gushchin@linux.dev> wrote:
>
> On Fri, Jan 12, 2024 at 11:04:06AM -0800, Shakeel Butt wrote:
> > On Thu, Jan 11, 2024 at 11:28 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
> > >
> > [...]
> > >
> > > From 6124a13cb073f5ff06b9c1309505bc937d65d6e5 Mon Sep 17 00:00:00 2001
> > > From: Johannes Weiner <hannes@cmpxchg.org>
> > > Date: Thu, 11 Jan 2024 07:18:47 -0500
> > > Subject: [PATCH] mm: memcontrol: don't throttle dying tasks on memory.high
> > >
> > > While investigating hosts with high cgroup memory pressures, Tejun
> > > found culprit zombie tasks that had were holding on to a lot of
> > > memory, had SIGKILL pending, but were stuck in memory.high reclaim.
> > >
> > > In the past, we used to always force-charge allocations from tasks
> > > that were exiting in order to accelerate them dying and freeing up
> > > their rss. This changed for memory.max in a4ebf1b6ca1e ("memcg:
> > > prohibit unconditional exceeding the limit of dying tasks"); it noted
> > > that this can cause (userspace inducable) containment failures, so it
> > > added a mandatory reclaim and OOM kill cycle before forcing charges.
> > > At the time, memory.high enforcement was handled in the userspace
> > > return path, which isn't reached by dying tasks, and so memory.high
> > > was still never enforced by dying tasks.
> > >
> > > When c9afe31ec443 ("memcg: synchronously enforce memory.high for large
> > > overcharges") added synchronous reclaim for memory.high, it added
> > > unconditional memory.high enforcement for dying tasks as well. The
> > > callstack shows that this path is where the zombie is stuck in.
> > >
> > > We need to accelerate dying tasks getting past memory.high, but we
> > > cannot do it quite the same way as we do for memory.max: memory.max is
> > > enforced strictly, and tasks aren't allowed to move past it without
> > > FIRST reclaiming and OOM killing if necessary. This ensures very small
> > > levels of excess. With memory.high, though, enforcement happens lazily
> > > after the charge, and OOM killing is never triggered. A lot of
> > > concurrent threads could have pushed, or could actively be pushing,
> > > the cgroup into excess. The dying task will enter reclaim on every
> > > allocation attempt, with little hope of restoring balance.
> > >
> > > To fix this, skip synchronous memory.high enforcement on dying tasks
> > > altogether again. Update memory.high path documentation while at it.
> > >
> > > Fixes: c9afe31ec443 ("memcg: synchronously enforce memory.high for large overcharges")
> > > Reported-by: Tejun Heo <tj@kernel.org>
> > > Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> >
> > Acked-by: Shakeel Butt <shakeelb@google.com>
> >
> > I am wondering if you have seen or suspected a similar issue but for
> > remote memcg charging. For example pageout on a global reclaim which
> > has to allocate buffers for some other memcg.
>
> You mean dying tasks entering a direct reclaim mode?
> Or kswapd being stuck in the reclaim path?
No, a normal task (not dying and not kswapd) doing global reclaim and
may have to do pageout which may trigger allocation of buffer head in
folio_alloc_buffers(). We increase current->memcg_nr_pages_over_high
irrespective of current in target memcg or not. Basically I just want
to know if this is a real concern or can be ignored for now.
prev parent reply other threads:[~2024-01-12 21:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-11 13:29 [PATCH] mm: memcontrol: don't throttle dying tasks on memory.high Johannes Weiner
2024-01-11 13:55 ` Yosry Ahmed
2024-01-11 16:50 ` Shakeel Butt
2024-01-11 17:59 ` Roman Gushchin
2024-01-11 19:28 ` Johannes Weiner
2024-01-11 19:38 ` Roman Gushchin
2024-01-11 19:49 ` Johannes Weiner
2024-01-12 17:06 ` Michal Hocko
2024-01-12 17:10 ` Roman Gushchin
2024-01-12 17:23 ` Michal Hocko
2024-01-12 19:04 ` Shakeel Butt
2024-01-12 20:59 ` Roman Gushchin
2024-01-12 21:27 ` Shakeel Butt [this message]
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='CALvZod5nLdpLgweBU0MtsMzBK=vTnJnRgr5FAhku3d=Atw1Cow@mail.gmail.com' \
--to=shakeelb@google.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=schatzberg.dan@gmail.com \
--cc=tj@kernel.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).