From: Johannes Weiner <hannes@cmpxchg.org>
To: Shakeel Butt <shakeelb@google.com>
Cc: "Roman Gushchin" <guro@fb.com>,
"Michal Hocko" <mhocko@kernel.org>,
"Yang Shi" <yang.shi@linux.alibaba.com>,
"Greg Thelen" <gthelen@google.com>,
"David Rientjes" <rientjes@google.com>,
"Michal Koutný" <mkoutny@suse.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Linux MM" <linux-mm@kvack.org>,
Cgroups <cgroups@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] memcg: introduce per-memcg reclaim interface
Date: Thu, 1 Oct 2020 11:10:58 -0400 [thread overview]
Message-ID: <20201001151058.GB493631@cmpxchg.org> (raw)
In-Reply-To: <CALvZod7afgoAL7KyfjpP-LoSFGSHv7XtfbbnVhEEhsiZLqZu9A@mail.gmail.com>
Hello Shakeel,
On Wed, Sep 30, 2020 at 08:26:26AM -0700, Shakeel Butt wrote:
> On Mon, Sep 28, 2020 at 2:03 PM Johannes Weiner <hannes@cmpxchg.org> wrote:
> > Workloads may not
> > allocate anything for hours, and then suddenly allocate gigabytes
> > within seconds. A sudden onset of streaming reads through the
> > filesystem could destroy the workingset measurements, whereas a limit
> > would catch it and do drop-behind (and thus workingset sampling) at
> > the exact rate of allocations.
> >
> > Again I believe something that may be doable as a hyperscale operator,
> > but likely too fragile to get wider applications beyond that.
> >
> > My take is that a proactive reclaim feature, whose goal is never to
> > thrash or punish but to keep the LRUs warm and the workingset trimmed,
> > would ideally have:
> >
> > - a pressure or size target specified by userspace but with
> > enforcement driven inside the kernel from the allocation path
> >
> > - the enforcement work NOT be done synchronously by the workload
> > (something I'd argue we want for *all* memory limits)
> >
> > - the enforcement work ACCOUNTED to the cgroup, though, since it's the
> > cgroup's memory allocations causing the work (again something I'd
> > argue we want in general)
>
> For this point I think we want more flexibility to control the
> resources we want to dedicate for proactive reclaim. One particular
> example from our production is the batch jobs with high memory
> footprint. These jobs don't have enough CPU quota but we do want to
> proactively reclaim from them. We would prefer to dedicate some amount
> of CPU to proactively reclaim from them independent of their own CPU
> quota.
Would it not work to add headroom for this reclaim overhead to the CPU
quota of the job?
The reason I'm asking is because reclaim is only one side of the
proactive reclaim medal. The other side is taking faults and having to
do IO and/or decompression (zswap, compressed btrfs) on the workload
side. And that part is unavoidably consuming CPU and IO quota of the
workload. So I wonder how much this can generally be separated out.
It's certainly something we've been thinking about as well. Currently,
because we use memory.high, we have all the reclaim work being done by
a privileged daemon outside the cgroup, and the workload pressure only
stems from the refault side.
But that means a workload is consuming privileged CPU cycles, and the
amount varies depending on the memory access patterns - how many
rotations the reclaim scanner is doing etc.
So I do wonder whether this "cost of business" of running a workload
with a certain memory footprint should be accounted to the workload
itself. Because at the end of the day, the CPU you have available will
dictate how much memory you need, and both of these axes affect how
you can schedule this job in a shared compute pool. Do neighboring
jobs on the same host leave you either the memory for your colder
pages, or the CPU (and IO) to trim them off?
For illustration, compare extreme examples of this.
A) A workload that has its executable/libraries and a fixed
set of hot heap pages. Proactive reclaim will be relatively
slow and cheap - a couple of deactivations/rotations.
B) A workload that does high-speed streaming IO and generates
a lot of drop-behind cache; or a workload that has a huge
virtual anon set with lots of allocations and MADV_FREEing
going on. Proactive reclaim will be fast and expensive.
Even at the same memory target size, these two types of jobs have very
different requirements toward the host environment they can run on.
It seems to me that this is cost that should be captured in the job's
overall resource footprint.
next prev parent reply other threads:[~2020-10-01 15:12 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-09 21:57 Shakeel Butt
2020-09-10 6:36 ` SeongJae Park
2020-09-10 16:10 ` Shakeel Butt
2020-09-10 16:34 ` SeongJae Park
2020-09-21 16:30 ` Michal Hocko
2020-09-21 17:50 ` Shakeel Butt
2020-09-22 11:49 ` Michal Hocko
2020-09-22 15:54 ` Shakeel Butt
2020-09-22 16:55 ` Michal Hocko
2020-09-22 18:10 ` Shakeel Butt
2020-09-22 18:31 ` Michal Hocko
2020-09-22 18:56 ` Shakeel Butt
2020-09-22 19:08 ` Michal Hocko
2020-09-22 20:02 ` Yang Shi
2020-09-22 22:38 ` Shakeel Butt
2020-09-28 21:02 ` Johannes Weiner
2020-09-29 15:04 ` Michal Hocko
2020-09-29 21:53 ` Johannes Weiner
2020-09-30 15:45 ` Shakeel Butt
2020-10-01 14:31 ` Johannes Weiner
2020-10-06 16:55 ` Shakeel Butt
2020-10-08 14:53 ` Johannes Weiner
2020-10-08 15:55 ` Shakeel Butt
2020-10-08 21:09 ` Johannes Weiner
2020-09-30 15:26 ` Shakeel Butt
2020-10-01 15:10 ` Johannes Weiner [this message]
2020-10-05 21:59 ` Shakeel Butt
2020-10-08 15:14 ` 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=20201001151058.GB493631@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=gthelen@google.com \
--cc=guro@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=rientjes@google.com \
--cc=shakeelb@google.com \
--cc=yang.shi@linux.alibaba.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