From: David Rientjes <rientjes@google.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Michal Hocko <mhocko@kernel.org>, Yu Zhao <yuzhao@google.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
linux-mm@kvack.org, Yosry Ahmed <yosryahmed@google.com>,
Wei Xu <weixugc@google.com>, Shakeel Butt <shakeelb@google.com>,
Greg Thelen <gthelen@google.com>
Subject: Re: [RFC] Mechanism to induce memory reclaim
Date: Wed, 9 Mar 2022 14:30:24 -0800 (PST) [thread overview]
Message-ID: <3c1589b-d558-72a2-8166-c289643d732d@google.com> (raw)
In-Reply-To: <YiZwHHQ0+CFL78Sb@cmpxchg.org>
On Mon, 7 Mar 2022, Johannes Weiner wrote:
> > IOW, this would be a /sys/devices/system/node/nodeN/reclaim mechanim for
> > each NUMA node N on the system. (It would be similar to the existing
> > per-node sysfs "compact" mechanism used to trigger compaction from
> > userspace.)
>
> I generally think a proactive reclaim interface is a good idea.
>
> A per-cgroup control knob would make more sense to me, as cgroupfs
> takes care of delegation, namespacing etc. and so would permit
> self-directed proactive reclaim inside containers.
>
This is an interesting point and something that would need to be decided.
There's pros and cons to both approaches, per-cgroup mechanism vs purely a
per-node sysfs mechanism that can take a cgroup id.
The reason we'd like this in sysfs is because of users who do not enable
CONFIG_MEMCG but would still benefit from proactive reclaim. Such users
do exist and do not rely on memcg, such as Chrome OS, and from my
understanding this is normally done to speed up hibernation.
But I note your use of "per-cgroup" control knob and not specifically
"per-memcg". Were you considering a proactive reclaim mechanism for a
cgroup other than memcg? A new one?
I'm wondering if it would make sense for such a cgroup interface, if
eventually needed, to be added incrementally on top of a per-node sysfs
interface. (We know today that there is a need for proactive reclaim for
users who do not use memcg at all.)
> > Userspace would write the following to this file:
> > - nr_to_reclaim pages
>
> This makes sense, although (and you hinted at this below), I'm
> thinking it should be in bytes, especially if part of cgroupfs.
>
If we agree upon a sysfs interface I assume there would be no objection to
this in nr_to_reclaim pages? I agree if this is to be a memcg knob that
it should be expressed in bytes for consistency with other knobs.
> > - swappiness factor
>
> This I'm not sure about.
>
> Mostly because I'm not sure about swappiness in general. It balances
> between anon and file, but both of them are aged according to the same
> LRU rules. The only reason to prefer one over the other seems to be
> when the cost of reloading one (refault vs swapin) isn't the same as
> the other. That's usually a hardware property, which in a perfect
> world we'd auto-tune inside the kernel based on observed IO
> performance. Not sure why you'd want this per reclaim request.
>
> > - flags to specify context, if any[**]
> >
> > [**] this is offered for extensibility to specify the context in which
> > reclaim is being done (clean file pages only, demotion for memory
> > tiering vs eviction, etc), otherwise 0
>
> This one is curious. I don't understand the use cases for either of
> these examples, and I can't think of other flags a user may pass on a
> per-invocation basis. Would you care to elaborate some?
>
If we combine the above two concerns, maybe only a flags argument is
sufficient where you can specify only anon or only file (and neither means
both)? What is controllable by swappiness could be controlled by two
different writes to the interface, one for (possibly) anon and one for
(possibly) file.
There was discussion about treating the two different types of memory
differently as a function of reload cost, cost of doing I/O for discard,
and how much swap space we want proactive reclaim to take, as well as the
only current alternative is to be playing with the global vm.swappiness.
Michal asked if this would include slab reclaim or shrinkers, I think the
answer is "possibly yes," but no initial use case for this (flags would be
extensible to permit the addition of it incrementally). In fact, if you
were to pass a cgroup id of 0 to induce global proactive reclaim you could
mimic the same control we have with vm.drop_caches today but does not
include reclaiming all of a memory type.
next prev parent reply other threads:[~2022-03-09 22:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-06 23:11 David Rientjes
2022-03-07 0:49 ` Yu Zhao
2022-03-07 14:41 ` Michal Hocko
2022-03-07 18:31 ` Shakeel Butt
2022-03-07 20:26 ` Johannes Weiner
2022-03-08 12:53 ` Michal Hocko
2022-03-08 14:44 ` Dan Schatzberg
2022-03-08 16:05 ` Michal Hocko
2022-03-08 17:21 ` Wei Xu
2022-03-08 17:23 ` Johannes Weiner
2022-03-08 12:52 ` Michal Hocko
2022-03-09 22:03 ` David Rientjes
2022-03-10 16:58 ` Johannes Weiner
2022-03-10 17:25 ` Shakeel Butt
2022-03-10 17:33 ` Wei Xu
2022-03-10 17:42 ` Johannes Weiner
2022-03-07 20:50 ` Johannes Weiner
2022-03-07 22:53 ` Wei Xu
2022-03-08 12:53 ` Michal Hocko
2022-03-08 14:49 ` Dan Schatzberg
2022-03-08 19:27 ` Johannes Weiner
2022-03-08 22:37 ` Dan Schatzberg
2022-03-09 22:30 ` David Rientjes [this message]
2022-03-10 16:10 ` 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=3c1589b-d558-72a2-8166-c289643d732d@google.com \
--to=rientjes@google.com \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@linux.intel.com \
--cc=gthelen@google.com \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=shakeelb@google.com \
--cc=weixugc@google.com \
--cc=yosryahmed@google.com \
--cc=yuzhao@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